Awesome
to-file-path
Create a filepath from an object path (dot notation), list of arguments, array, number or Arguments object.
You might also be interested in ip-filter or to-object-path.
Install
npm i to-file-path --save
Usage
For more use-cases see the tests
const toFilePath = require('to-file-path')
toFilePath
Create filepath from different type of arguments.
Params
args
{String|Array|Arguments|Number|Boolean}: Pass any type and any number of arguments.returns
{String}: always slash separated filepath
Example
var toFilePath = require('to-file-path')
console.log(toFilePath('foo.bar.baz')) // => 'foo/bar/baz'
console.log(toFilePath('foo.bar', 'qux.baz', 'xxx')) // => 'foo/bar/qux/baz/xxx'
console.log(toFilePath('foo', 'qux', 'baz')) // => 'foo/qux/baz'
console.log(toFilePath([1, 2, 3], 'foo', 4, 'bar')) // => '1/2/3/foo/4/bar'
console.log(toFilePath(null, true)) // => 'null/true'
console.log(toFilePath(1, 2, 3)) // => '1/2/3'
Related
- arr-includes: Return true if any of passed values exists in array. Using in-array. | homepage
- arr-map: Faster, node.js focused alternative to JavaScript's native array map. | homepage
- get-fn-name: Get function name with strictness and correctness in mind. Also works for… more | homepage
- in-array: Return true if a value exists in an array. Faster than using… more | homepage
- ip-filter: Filter valid IPv4 or IPv6 IP against glob pattern, array, string, regexp… more | homepage
- to-object-path: Create an object path from a list or array of strings. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.