path.mjs provides functions for FS paths. Features:
- Various common operations such as path joining, relativity, getting dirname/filename/extension, and more.
- Only string operations, no IO.
- OS-unaware. Provides separate implementations for Posix and Windows.
- Tiny, no external dependencies.
Known limitations:
- Insufficient documentation.
- Immature. Tests may be incomplete.
- Performance has not been optimized.
Using a specific implementation:
import * as p from 'https://cdn.jsdelivr.net/npm/@mitranim/[email protected]/path.mjs'
console.log(p.posix.join(`one`, `two`))
// 'one/two'
console.log(p.windows.join(`one`, `two`))
// 'one\\two'
Using the default implementation for the current OS:
import {paths as p} from 'https://cdn.jsdelivr.net/npm/@mitranim/[email protected]/io_deno.mjs'
console.log(p.join(`one`, `two`))
// 'one/two' or 'one\\two' depending on your OS
Links: source; test/example.
Idempotently converts a path from Windows-style to Posix-style. Useful in some edge case scenarios.
import * as p from 'https://cdn.jsdelivr.net/npm/@mitranim/[email protected]/path.mjs'
console.log(p.toPosix(`one\\two\\three`))
// 'one/two/three'
console.log(p.toPosix(`one/two/three`))
// 'one/two/three'
Links: source; test/example.
Implements various functions for Posix-style FS paths.
Links: source; test/example.
Implements various functions for Windows-style FS paths.
The following APIs are exported but undocumented. Check path.mjs.