Remove leading directory components from a path, like tar's --strip-components option
npm install strip-dirs



Remove leading directory components from a path, like tar(1)'s --strip-components option
``javascript
const stripDirs = require('strip-dirs');
stripDirs('foo/bar/baz', 1); //=> 'bar/baz'
stripDirs('foo/bar/baz', 2); //=> 'baz'
stripDirs('foo/bar/baz', 999); //=> 'baz'
`
``
npm install strip-dirs
`javascript`
const stripDirs = require('strip-dirs');
path: string (A relative path) integer
count: (>= 0) Object
option: string
Return:
It removes directory components from the beginning of the path by count.
`javascript
const stripDirs = require('strip-dirs');
stripDirs('foo/bar', 1); //=> 'bar'
stripDirs('foo/bar/baz', 2); //=> 'bar'
stripDirs('foo/././/bar/./', 1); //=> 'bar'
stripDirs('foo/bar', 0); //=> 'foo/bar'
stripDirs('/foo/bar', 1) // throw an error because the path is an absolute path
`
If you want to remove all directory components certainly, use path.basename instead of this module.
#### option.disallowOverflow
Type: boolean false
Default:
By default, it keeps the last path component when path components are fewer than the count.
If this option is enabled, it throws an error in this situation.
`javascript
stripDirs('foo/bar/baz', 9999); //=> 'baz'
stripDirs('foo/bar/baz', 9999, {disallowOverflow: true}); // throws an range error
``
ISC License © 2017 - 2018 Shinnosuke Watanabe