Skip to content
Node.js path.dirname() ponyfill
Branch: master
Clone or download
Latest commit ba28247 Oct 18, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml Init Oct 18, 2016
appveyor.yml
index.js Actually use the posix version Oct 18, 2016
license Init Oct 18, 2016
package.json
readme.md
test.js Fix require Oct 18, 2016

readme.md

path-dirname Build Status

Node.js path.dirname() ponyfill

This was needed in order to expose path.posix.dirname() on Node.js v0.10

Install

$ npm install --save path-dirname

Usage

const pathDirname = require('path-dirname');

pathDirname('/home/foo');
//=> '/home'
pathDirname('C:\\Users\\foo');
//=> 'C:\\Users'
pathDirname('foo');
//=> '.'
pathDirname('foo/bar');
//=> 'foo'

//Using posix version for consistent output when dealing with glob escape chars
pathDirname.win32('C:\\Users\\foo/\\*bar');
//=> 'C:\\Users\\foo/'
pathDirname.posix('C:\\Users\\foo/\\*bar');
//=> 'C:\\Users\\foo'

API

See the path.dirname() docs.

pathDirname(path)

pathDirname.posix(path)

POSIX specific version.

pathDirname.win32(path)

Windows specific version.

License

MIT

You can’t perform that action at this time.