path-segments
Get specific segments of a file path. First, last, last two, first two, etc.
Install
Install with npm:
npm i path-segments --save-dev
Usage
var segements = ;
Tests
In the command line, run npm test
or mocha
.
first
Get the first n
segments of a path:
;//=> 'a';//=> 'a';//=> 'a';//=> 'a';//=> 'a';//=> 'a';//=> 'a/b';//=> 'a/b';//=> 'a/b/c.js';//=> 'a/b/c';//=> 'a/b/c';//=> 'a/b/c';//=> 'a/b/c.js'
last
Get the last n
segments of a path:
;//=> 'c';//=> 'c';//=> 'c.js';//=> 'c.js';//=> 'c';//=> 'c';//=> 'c.js';//=> 'b/c.js';//=> 'b/c';//=> 'b/c';//=> 'b/c.js';//=> 'a/b/c';//=> 'a/b/c.js';//=> 'a/b/c';//=> 'a/b/c.js'
See the tests for more examples.
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on June 26, 2014.