@fav/path.basename
v0.9.0
Published
Provides same behaviors of `path.basename` module for all versions of node.js
Downloads
11
Readme
@fav/path.basename
Provides same behaviors of path.basename
module for all versions of node.js
Install
For installing @fav/path
with npm:
$ npm install @fav/path --save
For installing only @fav/path.basename
with npm:
$ npm install @fav/path.basename --save
Usage
When installing @fav/path
:
const path = require('@fav/path');
path.basename('path/to/file.ext');
// => file.ext
path.basename('path/to/file.ext', '.ext');
// => file
When installing @fav/path.basename
:
const basename = require('@fav/path.basename');
basename('path/to/file.ext');
// => file.ext
basename('path/to/file.ext', '.ext');
// => file
API
basename(path, [, ext])
Returns a basename of a file path.
Arguments
- path [string] : an absolute or relative path string.
- ext [string] : an extension (optional).
Errors
- [TypeError] : if path is not a string, or ext is given and not a string.
License
Copyright (C) 2016 Takayuki Sato
This program is free software under MIT License. See the file LICENSE in this distribution for more details.