[to-file-path][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url]

March 25, 2016 · View on GitHub

Create a filepath from an object path (dot notation), list of arguments, array, number or Arguments object.

code climate standard code style travis build status coverage status dependency status

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'

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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github