Installations
npm install @igor.dvlpr/upath
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=20.0
Node Version
22.4.0
NPM Version
10.8.1
Score
67.1
Supply Chain
98.5
Quality
77.7
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
Download Statistics
Total Downloads
5,622
Last Day
2
Last Week
15
Last Month
71
Last Year
1,244
GitHub Statistics
1 Stars
89 Commits
2 Watching
1 Branches
1 Contributors
Bundle Size
843.00 B
Minified
440.00 B
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
3.0.1
Package Id
@igor.dvlpr/upath@3.0.1
Unpacked Size
10.65 kB
Size
3.76 kB
File Count
5
NPM Version
10.8.1
Node Version
22.4.0
Publised On
04 Jul 2024
Total Downloads
Cumulative downloads
Total Downloads
5,622
Last day
100%
2
Compared to previous day
Last week
-66.7%
15
Compared to previous week
Last month
24.6%
71
Compared to previous month
Last year
-22.3%
1,244
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
4
uPath
🎍 Provides a universal way of formatting file-paths in Unix-like and Windows operating systems as an alternative to the built-in path.normalize(). 🧬
💖 Support further development
I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. ☕
Thank you for supporting my efforts! 🙏😊
@igorskyflyer
Why
uPath
? Simple. Working with file paths insideString
s in Windows + JavaScript is a hassle. By callingu()
, the file path you provided is converted to your OS-preferred file path format, i.e. you can get away with writing "C:/Users/JohnDoe/
" without having to worry about those backslashes that Windows uses. On the other hand, UNIX-like slashes in file paths are left as-is. An extra feature thatuPath
provides is redundant trailing slash removal.
✨Since version 1.2.0
support for UNC paths has been added, thanks to unc-path.
🕵🏼 Usage
Install it by executing:
1npm i "@igor.dvlpr/upath"
🤹🏼 API
upath()
=>
returns a proper file path depending on the host OS.
✨Note: upath()
has an alias, named u()
for your convenience.
Signature
1upath(fsPath: string, addTrailingSlash: boolean = false): string
1u(fsPath: string, addTrailingSlash: boolean = false): string
Parameters
1fsPath: string // a string that represents the path to process, 2 3addTrailingSlash: boolean = false 4// a boolean that represents whether a trailing slash should be added to the fsPath or not
Example - Windows OS
1import { u } from '@igor.dvlpr/upath' 2 3console.log(u('C:/')) // returns 'C:\\' 4console.log(u('C:/WINDOWS//////')) // returns 'C:\\WINDOWS\\' 5console.log(u('C:/Users', true)) // returns 'C:\\Users\\' 6console.log(u('\\\\ComputerName\\SharedFolder')) // returns '\\\\ComputerName\\SharedFolder' 7console.log(u('//ComputerName/SharedFolder')) // returns '\\\\ComputerName\\SharedFolder'
Example - UNIX-like OS
1import { u } from '@igor.dvlpr/upath' 2 3console.log(u('/mnt/')) // returns '/mnt/' 4console.log(u('/usr/bin/////////')) // returns '/usr/bin/' 5console.log(u('/usr/bin', true)) // returns '/usr/bin/' 6console.log(u('//ComputerName/SharedFolder')) // returns '//ComputerName/SharedFolder' 7console.log(u('\\\\ComputerName\\SharedFolder')) // returns '//ComputerName/SharedFolder'
uw()
=>
returns a proper file path for Windows operating system.
Signature
1uw(fsPath: string, addTrailingSlash: boolean = false): string
Parameters
1fsPath: string // a string that represents the path to process, 2 3addTrailingSlash: boolean = false 4// a boolean that represents whether a trailing slash should be added to the fsPath or not
Example - Any OS
1import { uw } from '@igor.dvlpr/upath' 2 3console.log(uw('C:/WINDOWS/System32')) // returns 'C:\\WINDOWS\\System32' 4console.log(uw('//ComputerName/SharedFolder')) // returns '\\\\ComputerName\\SharedFolder'
ux()
=>
returns a proper file path for UNIX-like operating systems.
Signature
1ux(fsPath: string, addTrailingSlash: boolean = false): string
Parameters
1fsPath: string // a string that represents the path to process, 2 3addTrailingSlash: boolean = false 4// a boolean that represents whether a trailing slash should be added to the fsPath or not
Example - Any OS
1import { ux } from '@igor.dvlpr/upath' 2 3console.log(ux('/usr/local')) // returns '/usr/local' 4console.log(ux('\\\\ComputerName\\SharedFolder')) 5// returns '//ComputerName/SharedFolder'
✨ Since v.1.0.3
a string property named slash
is exposed as well, provides an easy way to access file path OS-specific delimiter.
On Windows
slash = '\\'
.
On UNIX-like
slash = '/'
.
🪪 License
Licensed under the MIT license which is available here, MIT license.
🧬 Related
✒ DúöScríbî allows you to convert letters with diacritics to regular letters. 🤓
🧬 A lightweight JavaScript utility allowing deep copy-by-value of nested objects, arrays and arrays of objects. 🪁
🧵 Provides ways of checking whether a String is present in an Array of Strings using custom Comparators. 🔍
🔱 Odin is an Object wrapper that allows you to create objects and set their attributes - all at once! 🔺
🧮 Calculates an estimated file size of Mp3 files. 🎶
Provided by Igor Dimitrijević (@igorskyflyer).
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Score
2.4
/10
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More