Powerful path manipulation utilities for Node.js with zero dependencies.
- Extract file names, extensions, and directory information
- Asynchronous file existence checking
- Zero dependencies
- Modern ES modules support
- Node.js >=22.0.0
# npm
npm install @iohub/pathinfo
# yarn
yarn add @iohub/pathinfo
# pnpm
pnpm add @iohub/pathinfo
import { pathToName, pathToNameExt, pathToEntry, pathToInfo, exists } from '@iohub/pathinfo'
// Extract file name without extension
pathToName('path/to/file.txt') // => 'file'
// Get file name with extension
pathToNameExt('path/to/file.txt') // => 'file.txt'
// Get file name and extension as array
pathToEntry('path/to/file.txt') // => ['file', '.txt']
// Get complete path information
pathToInfo('path/to/file.txt') // => { dir: 'path/to', doc: 'file', ext: '.txt' }
// Check if path exists
await exists('path/to/file.txt') // => true/false
MIT © Hoyeung Wong