strip-dirs

WebJar for strip-dirs

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

strip-dirs
Last Version

Last Version

3.0.0-0
Release Date

Release Date

Type

Type

jar
Description

Description

strip-dirs
WebJar for strip-dirs
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/shinnn/node-strip-dirs

Download strip-dirs

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/strip-dirs/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>strip-dirs</artifactId>
    <version>3.0.0-0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/strip-dirs/
implementation 'org.webjars.npm:strip-dirs:3.0.0-0'
// https://jarcasting.com/artifacts/org.webjars.npm/strip-dirs/
implementation ("org.webjars.npm:strip-dirs:3.0.0-0")
'org.webjars.npm:strip-dirs:jar:3.0.0-0'
<dependency org="org.webjars.npm" name="strip-dirs" rev="3.0.0-0">
  <artifact name="strip-dirs" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='strip-dirs', version='3.0.0-0')
)
libraryDependencies += "org.webjars.npm" % "strip-dirs" % "3.0.0-0"
[org.webjars.npm/strip-dirs "3.0.0-0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : is-natural-number jar [4.0.1,5)

Project Modules

There are no modules declared in this project.

strip-dirs

npm version Build Status Coverage Status

Remove leading directory components from a path, like tar(1)'s --strip-components option

const stripDirs = require('strip-dirs');

stripDirs('foo/bar/baz', 1); //=> 'bar/baz'
stripDirs('foo/bar/baz', 2); //=> 'baz'
stripDirs('foo/bar/baz', 999); //=> 'baz'

Installation

Use npm.

npm install strip-dirs

API

const stripDirs = require('strip-dirs');

stripDirs(path, count [, option])

path: string (A relative path)
count: integer (>= 0)
option: Object
Return: string

It removes directory components from the beginning of the path by count.

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
Default: false

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.

stripDirs('foo/bar/baz', 9999); //=> 'baz'

stripDirs('foo/bar/baz', 9999, {disallowOverflow: true}); // throws an range error

License

ISC License © 2017 - 2018 Shinnosuke Watanabe

Versions

Version
3.0.0-0