@fav/path.format

0.9.0 • Public • Published

@fav/path.format NPM version

Provides same behaviors of path.format module for all versions of node.js

Install

For installing @fav/path with npm:

$ npm install @fav/path --save

For installing only @fav/path.format with npm:

$ npm install @fav/path.format --save

Usage

When installing @fav/path:

const path = require('@fav/path');

path.format({ dir: 'path/to', base: 'file.ext' });
// => path/to/file.ext

path.format({ dir: 'path/to', name: 'file', ext: '.ext' });
// => path/to/file.ext

When installing @fav/path.format:

const format = require('@fav/path.format');

format({ dir: 'path/to', base: 'file.ext' });
// => path/to/file.ext

format({ dir: 'path/to', name: 'file', ext: '.ext' });
// => path/to/file.ext

API

format(pathObject)

Returns a path string from an object.

Arguments
  • pathObject [object] :

    pathObject can has following properties:

    • dir : a string for a directory.
    • root : a string for a root. This property is used if dir property is not supplied.
    • base : a string for a base name.
    • name : a string for a file name without an extension. This property is used if base property is not supplied.
    • ext : a string for an extension. This property is used if base property is not supplied.
Errors
  • [TypeError] : if path is not an object.

License

Copyright (C) 2016 Takayuki Sato

This program is free software under MIT License. See the file LICENSE in this distribution for more details.

Dependents (0)

Package Sidebar

Install

npm i @fav/path.format

Weekly Downloads

1

Version

0.9.0

License

MIT

Last publish

Collaborators

  • sttk