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-agnostic.
- Supports Windows volumes.
- Always normalizes
\to/.
- Tiny, no external dependencies.
- Can be customized via subclassing.
Known limitations:
- Insufficient documentation.
- Immature. Tests may be incomplete.
- Performance has not been optimized.
Using a specific implementation:
import * as pt from 'https://cdn.jsdelivr.net/npm/@mitranim/js@0.1.85/path.mjs'
console.log(pt.join(`one`, `two`, `three.four`))
// 'one/two/three.four'
console.log(pt.dir(`one/two/three.four`))
// 'one/two'
console.log(pt.name(`one/two/three.four`))
// 'three.four'
console.log(pt.stem(`one/two/three.four`))
// 'three'The following APIs are exported but undocumented. Check path.mjs.
const SEP_WINDOWSconst SEP_POSIXconst SEP_ENVconst EXT_SEPconst CWD_RELconst PAR_RELfunction toPosixfunction toWindowsfunction normfunction cleanfunction isRootfunction isCwdRelfunction isAbsfunction isRelfunction isRelExplicitfunction isRelImplicitfunction isDirLikefunction joinfunction isSubOffunction strictRelTofunction relTofunction dirLikefunction dirfunction volumefunction hasVolumefunction namefunction extfunction hasExtfunction stemfunction replaceSepclass Pathsdefault paths