@iohub/pathinfo

0.0.4 • Public • Published

@iohub/pathinfo

Powerful path manipulation utilities for Node.js with zero dependencies.

npm version npm downloads npm license github commit activity

Features

  • Extract file names, extensions, and directory information
  • Asynchronous file existence checking
  • Zero dependencies
  • Modern ES modules support
  • Node.js >=22.0.0

Installation

# npm
npm install @iohub/pathinfo

# yarn
yarn add @iohub/pathinfo

# pnpm
pnpm add @iohub/pathinfo

Usage

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

License

MIT © Hoyeung Wong

Package Sidebar

Install

npm i @iohub/pathinfo

Weekly Downloads

7

Version

0.0.4

License

BSD

Unpacked Size

5.03 kB

Total Files

4

Last publish

Collaborators

  • hoyeung