1.0.1 • Published 9 years ago

get-first-from-filepath v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

npm mit license build status coverage status deps status

Get the very first directory name from file path ./foo/bar/baz -> foo or ../a/b/c -> ../a Useful when you just want first real directory from given file path

Install

npm i --save get-first-from-filepath
npm test

Usage

For more use-cases see the tests

var getFirstFromFilepath = require('get-first-from-filepath');

getFirstFromFilepath('foo/bar/baz');
//=> 'foo'

getFirstFromFilepath('/foo/bar/baz');
//=> 'foo'

getFirstFromFilepath('./foo/bar/baz');
//=> 'foo'

getFirstFromFilepath('../foo/bar/baz');
//=> '../foo'

getFirstFromFilepath('..foo/bar/baz');
//=> '..foo'

Author

Charlike Mike Reagent

License MIT license

Copyright (c) 2015 Charlike Mike Reagent, contributors.
Released under the MIT license.


Powered and automated by kdf, February 27, 2015