https://github.com/salsan/ispath
isPath is a Node.js package for validate if string is a Path of Operating System
https://github.com/salsan/ispath
Last synced: about 1 month ago
JSON representation
isPath is a Node.js package for validate if string is a Path of Operating System
- Host: GitHub
- URL: https://github.com/salsan/ispath
- Owner: salsan
- License: mit
- Created: 2021-08-21T16:26:22.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-16T07:05:07.000Z (6 months ago)
- Last Synced: 2025-04-30T22:13:49.775Z (about 1 month ago)
- Language: JavaScript
- Size: 372 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ispathjs
ispathjs is a Node.js package for validate if string is a Path of Operating SystemCurrent version support **Windows** and **Linux**
## Install
```bash
npm i ispathjs
```
## Usage>### **isPath()**
>
>return true if path is valid for Linux or Windows otherwise false>### **isPath.absolute()**
>
>return true if path is valid absolute path for Linux or Windows otherwise false>### **isPath.relative()**
>
>return true if path is valid relative path for Linux or Windows otherwise false>### **isPath.win32()**
>
>return true if path (absolute or relative) is valid for Windows otherwise false>### **isPath.win32.absolute()**
>
>return true if path is valid absolute path for Windows otherwise false>### **isPath.win32.relative()**
>
>return true if path is valid relative path for Windows otherwise false>### **isPath.unix()**
>
>return true if path (absolute or relative) is valid for Linux otherwise false>### **isPath.unix.absolute()**
>
>return true if path is valid absolute path for Linux otherwise false>### **isPath.unix.relative()**
>
>return true if path is valid relative path for Linux otherwise false# Example
```js
const isPath = require('ispathjs');const path = [
"C:\\Documents\\Newsletters\\Summer2018.pdf",
"\\Program Files\\Custom Utilities\\StringFinder.exe",
"2018\\January.xlsx",
"..\\Publications\\TravelBrochure.pdf",
"C:\\Projects\\apilibrary\\apilibrary.sln",
"C:Projects\\apilibrary\\apilibrary.sln"
];path.forEach(element => {
console.log(element, isPath.absolute(element))
});```
return a bolean value **true** or **false**
```bash
C:\Documents\Newsletters\Summer2018.pdf true
\Program Files\Custom Utilities\StringFinder.exe true
2018\January.xlsx false
..\Publications\TravelBrochure.pdf false
C:\Projects\apilibrary\apilibrary.sln true
C:Projects\apilibrary\apilibrary.sln false
```
# LicenseMIT License - Copyright 2021 Salvatore Santagati ()