|
| 1 | +# to-file-path [![npm version][npmv-img]][npmv-url] [![License][license-img]][license-url] [![Libera Manifesto][libera-manifesto-img]][libera-manifesto-url] |
| 2 | + |
| 3 | +> Create a filepath from an object path (dot notation), list of arguments, |
| 4 | +> array, number or Arguments object. |
| 5 | +
|
| 6 | +Please consider following this project's author, |
| 7 | +[Charlike Mike Reagent](https://github.com/tunnckoCore), and :star: the project |
| 8 | +to show your :heart: and support. |
| 9 | + |
| 10 | +<div id="readme"></div> |
| 11 | + |
| 12 | +[![Code style][codestyle-img]][codestyle-url] |
| 13 | +[![CircleCI linux build][linuxbuild-img]][linuxbuild-url] |
| 14 | +[![CodeCov coverage status][codecoverage-img]][codecoverage-url] |
| 15 | +[![Renovate App Status][renovateapp-img]][renovateapp-url] |
| 16 | +[![Make A Pull Request][prs-welcome-img]][prs-welcome-url] |
| 17 | +[![Time Since Last Commit][last-commit-img]][last-commit-url] |
| 18 | + |
| 19 | +<!-- [![Semantically Released][standard-release-img]][standard-release-url] --> |
| 20 | + |
| 21 | +If you have any _how-to_ kind of questions, please read the [Contributing |
| 22 | +Guide][contributing-url] and [Code of Conduct][code_of_conduct-url] documents. |
| 23 | +For bugs reports and feature requests, [please create an issue][open-issue-url] |
| 24 | +or ping [@tunnckoCore](https://twitter.com/tunnckoCore) at Twitter. |
| 25 | + |
| 26 | +[![Conventional Commits][ccommits-img]][ccommits-url] |
| 27 | +[![Minimum Required Nodejs][nodejs-img]][npmv-url] |
| 28 | +[![NPM Downloads Monthly][downloads-monthly-img]][npmv-url] |
| 29 | +[![NPM Downloads Total][downloads-total-img]][npmv-url] |
| 30 | +[![Share Love Tweet][twitter-share-img]][twitter-share-url] |
| 31 | +[![Twitter][twitter-img]][twitter-url] |
| 32 | + |
| 33 | +Project is [semantically](https://semver.org) versioned & automatically released |
| 34 | +from [GitHub Actions](https://github.com/features/actions) with |
| 35 | +[Lerna](https://github.com/lerna/lerna). |
| 36 | + |
| 37 | +[![Become a Patron][patreon-img]][patreon-url] |
| 38 | +[![Buy me a Kofi][kofi-img]][kofi-url] |
| 39 | +[![PayPal Donation][paypal-img]][paypal-url] |
| 40 | +[![Bitcoin Coinbase][bitcoin-img]][bitcoin-url] |
| 41 | +[![Keybase PGP][keybase-img]][keybase-url] |
| 42 | + |
| 43 | +| Topic | Contact | |
| 44 | +| :--------------------------------------------------------------- | ------------------------------------------------: | |
| 45 | +| Any legal or licensing questions, like private or commerical use | ![tunnckocore_legal][tunnckocore_legal] | |
| 46 | +| For any critical problems and security reports | ![tunnckocore_security][tunnckocore_security] | |
| 47 | +| Consulting, professional support, personal or team training | ![tunnckocore_consulting][tunnckocore_consulting] | |
| 48 | +| For any questions about Open Source, partnerships and sponsoring | ![tunnckocore_opensource][tunnckocore_opensource] | |
| 49 | + |
| 50 | +<!-- Logo when needed: |
| 51 | +
|
| 52 | +<p align="center"> |
| 53 | + <a href="https://github.com/tunnckoCore/opensource"> |
| 54 | + <img src="./media/logo.png" width="85%"> |
| 55 | + </a> |
| 56 | +</p> |
| 57 | +
|
| 58 | +--> |
| 59 | + |
| 60 | +## Table of Contents |
| 61 | + |
| 62 | +- [Install](#install) |
| 63 | +- [API](#api) |
| 64 | + - [toFilePath](#tofilepath) |
| 65 | +- [See Also](#see-also) |
| 66 | +- [Contributing](#contributing) |
| 67 | + - [Guides and Community](#guides-and-community) |
| 68 | + - [Support the project](#support-the-project) |
| 69 | +- [Contributors](#contributors) |
| 70 | +- [License](#license) |
| 71 | + |
| 72 | +_(TOC generated by [verb](https://github.com/verbose/verb) using |
| 73 | +[markdown-toc](https://github.com/jonschlinkert/markdown-toc))_ |
| 74 | + |
| 75 | +## Install |
| 76 | + |
| 77 | +This project requires [**Node.js**](https://nodejs.org) **>=10.13** _(see |
| 78 | +[Support & Release Policy](https://github.com/tunnckoCoreLabs/support-release-policy))_. |
| 79 | +Install it using [**yarn**](https://yarnpkg.com) or |
| 80 | +[**npm**](https://npmjs.com).<br> _We highly recommend to use Yarn when you |
| 81 | +think to contribute to this project._ |
| 82 | + |
| 83 | +```bash |
| 84 | +$ yarn add to-file-path |
| 85 | +``` |
| 86 | + |
| 87 | +## API |
| 88 | + |
| 89 | +<!-- docks-start --> |
| 90 | + |
| 91 | +_Generated using [jest-runner-docs](https://ghub.now.sh/jest-runner-docs)._ |
| 92 | + |
| 93 | +### [toFilePath](./src/index.js#L23) |
| 94 | + |
| 95 | +Create filepath from different type of arguments. |
| 96 | + |
| 97 | +<span id="tofilepath-signature"></span> |
| 98 | + |
| 99 | +#### Signature |
| 100 | + |
| 101 | +```ts |
| 102 | +function(args) |
| 103 | +``` |
| 104 | + |
| 105 | +<span id="tofilepath-params"></span> |
| 106 | + |
| 107 | +#### Params |
| 108 | + |
| 109 | +- `...args` **{string|array|Arguments|number|boolean}** - Pass any type and any |
| 110 | + number of arguments. |
| 111 | +- `returns` **{string}** - always slash separated filepath |
| 112 | + |
| 113 | +<span id="tofilepath-examples"></span> |
| 114 | + |
| 115 | +#### Examples |
| 116 | + |
| 117 | +```js |
| 118 | +const toFilePath = require('to-file-path'); |
| 119 | +
|
| 120 | +console.log(toFilePath('foo.bar.baz')); // => 'foo/bar/baz' |
| 121 | +console.log(toFilePath('foo.bar', 'qux.baz', 'xxx')); // => 'foo/bar/qux/baz/xxx' |
| 122 | +console.log(toFilePath('foo', 'qux', 'baz')); // => 'foo/qux/baz' |
| 123 | +console.log(toFilePath([1, 2, 3], 'foo', 4, 'bar')); // => '1/2/3/foo/4/bar' |
| 124 | +console.log(toFilePath(null, true)); // => 'null/true' |
| 125 | +console.log(toFilePath(1, 2, 3)); // => '1/2/3' |
| 126 | +``` |
| 127 | + |
| 128 | +<!-- docks-end --> |
| 129 | + |
| 130 | +**[back to top](#readme)** |
| 131 | + |
| 132 | +## See Also |
| 133 | + |
| 134 | +Some of these projects are used here or were inspiration for this one, others |
| 135 | +are just related. So, thanks for your existance! |
| 136 | + |
| 137 | +- [arr-includes](https://www.npmjs.com/package/arr-includes): Return positive |
| 138 | + value if (any of the) passed value(s) exists… |
| 139 | + [more](https://tunnckocore.com/opensource) | |
| 140 | + [homepage](https://tunnckocore.com/opensource 'Return positive value if (any of the) passed value(s) exists in array, or optionally an index') |
| 141 | +- [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused |
| 142 | + alternative to JavaScript's native array map. | |
| 143 | + [homepage](https://github.com/jonschlinkert/arr-map "Faster, node.js focused alternative to JavaScript's native array map.") |
| 144 | +- [get-fn-name](https://www.npmjs.com/package/get-fn-name): Get function name |
| 145 | + with strictness and correctness in mind. Also… |
| 146 | + [more](https://github.com/tunnckocore/get-fn-name#readme) | |
| 147 | + [homepage](https://github.com/tunnckocore/get-fn-name#readme 'Get function name with strictness and correctness in mind. Also works for arrow functions and getting correct name of bounded functions. Powered by [fn-name][].') |
| 148 | +- [in-array](https://www.npmjs.com/package/in-array): Return true if a value |
| 149 | + exists in an array. Faster… [more](https://github.com/jonschlinkert/in-array) |
| 150 | + | |
| 151 | + [homepage](https://github.com/jonschlinkert/in-array "Return true if a value exists in an array. Faster than using indexOf and won't blow up on null values.") |
| 152 | +- [ip-filter](https://www.npmjs.com/package/ip-filter): Validates valid IPs |
| 153 | + (IPv4 and IPv6) using [micromatch][] - glob… |
| 154 | + [more](https://github.com/tunnckocore/ip-filter#readme) | |
| 155 | + [homepage](https://github.com/tunnckocore/ip-filter#readme 'Validates valid IPs (IPv4 and IPv6) using [micromatch][] - glob patterns, RegExp, string or array of globs. If match returns the IP, otherwise null.') |
| 156 | +- [to-object-path](https://www.npmjs.com/package/to-object-path): Create an |
| 157 | + object path from a list or array of… |
| 158 | + [more](https://github.com/jonschlinkert/to-object-path) | |
| 159 | + [homepage](https://github.com/jonschlinkert/to-object-path 'Create an object path from a list or array of strings.') |
| 160 | + |
| 161 | +**[back to top](#readme)** |
| 162 | + |
| 163 | +## Contributing |
| 164 | + |
| 165 | +### Guides and Community |
| 166 | + |
| 167 | +Please read the [Contributing Guide][contributing-url] and [Code of |
| 168 | +Conduct][code_of_conduct-url] documents for advices. |
| 169 | + |
| 170 | +For bug reports and feature requests, please join our [community][community-url] |
| 171 | +forum and open a thread there with prefixing the title of the thread with the |
| 172 | +name of the project if there's no separate channel for it. |
| 173 | + |
| 174 | +Consider reading the |
| 175 | +[Support and Release Policy](https://github.com/tunnckoCoreLabs/support-release-policy) |
| 176 | +guide if you are interested in what are the supported Node.js versions and how |
| 177 | +we proceed. In short, we support latest two even-numbered Node.js release lines. |
| 178 | + |
| 179 | +### Support the project |
| 180 | + |
| 181 | +[Become a Partner or Sponsor?][kofi-url] :dollar: Check the **OpenSource** |
| 182 | +Commision (tier). :tada: You can get your company logo, link & name on this |
| 183 | +file. It's also rendered on package's page in [npmjs.com][npmv-url] and |
| 184 | +[yarnpkg.com](https://yarnpkg.com/en/package/to-file-path) sites too! :rocket: |
| 185 | + |
| 186 | +Not financial support? Okey! |
| 187 | +[Pull requests](https://github.com/tunnckoCoreLabs/contributing#opening-a-pull-request), |
| 188 | +stars and all kind of |
| 189 | +[contributions](https://opensource.guide/how-to-contribute/#what-it-means-to-contribute) |
| 190 | +are always welcome. :sparkles: |
| 191 | + |
| 192 | +## Contributors |
| 193 | + |
| 194 | +This project follows the |
| 195 | +[all-contributors](https://github.com/all-contributors/all-contributors) |
| 196 | +specification. Contributions of any kind are welcome! |
| 197 | + |
| 198 | +Thanks goes to these wonderful people |
| 199 | +([emoji key](https://allcontributors.org/docs/en/emoji-key)), consider showing |
| 200 | +your [support](#support-the-project) to them: |
| 201 | + |
| 202 | +<!-- ALL-CONTRIBUTORS-LIST:START --> |
| 203 | +<!-- prettier-ignore-start --> |
| 204 | +<!-- markdownlint-disable --> |
| 205 | +<table> |
| 206 | + <tr> |
| 207 | + <td align="center"><a href="https://tunnckoCore.com"><img src="https://avatars3.githubusercontent.com/u/5038030?v=4" width="100px;" alt=""/><br /><sub><b>Charlike Mike Reagent</b></sub></a><br /><a href="#infra-tunnckoCore" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/node-formidable/node-formidable/commits?author=tunnckoCore" title="Code">💻</a> <a href="https://github.com/node-formidable/node-formidable/commits?author=tunnckoCore" title="Documentation">📖</a> <a href="#ideas-tunnckoCore" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-tunnckoCore" title="Maintenance">🚧</a> <a href="https://github.com/node-formidable/node-formidable/commits?author=tunnckoCore" title="Tests">⚠️</a></td> |
| 208 | + </tr> |
| 209 | +</table> |
| 210 | + |
| 211 | +<!-- markdownlint-enable --> |
| 212 | +<!-- prettier-ignore-end --> |
| 213 | + |
| 214 | +<!-- ALL-CONTRIBUTORS-LIST:END --> |
| 215 | + |
| 216 | +**[back to top](#readme)** |
| 217 | + |
| 218 | +## License |
| 219 | + |
| 220 | +Copyright (c) 2016-present, [Charlike Mike Reagent](https://tunnckocore.com) |
| 221 | +`<[email protected]>` & [ contributors](# wonderful-contributors). <br> |
| 222 | +Released under the [MPL-2.0 License][license-url]. |
| 223 | + |
| 224 | +<!-- badges --> |
| 225 | + |
| 226 | +<!-- prettier-ignore-start --> |
| 227 | + |
| 228 | +[contributing-url]: https://github.com/tunnckoCore/opensource/blob/master/CONTRIBUTING.md |
| 229 | +[code_of_conduct-url]: https://github.com/tunnckoCore/opensource/blob/master/CODE_OF_CONDUCT.md |
| 230 | + |
| 231 | +<!-- Heading badges --> |
| 232 | + |
| 233 | +[npmv-url]: https://www.npmjs.com/package/to-file-path |
| 234 | +[npmv-img]: https://badgen.net/npm/v/to-file-path?icon=npm&cache=300 |
| 235 | + |
| 236 | +[license-url]: https://github.com/tunnckoCore/opensource/blob/master/packages/to-file-path/LICENSE |
| 237 | +[license-img]: https://badgen.net/npm/license/to-file-path?cache=300 |
| 238 | + |
| 239 | +[libera-manifesto-url]: https://liberamanifesto.com |
| 240 | +[libera-manifesto-img]: https://badgen.net/badge/libera/manifesto/grey |
| 241 | + |
| 242 | +<!-- Front line badges --> |
| 243 | + |
| 244 | +[codecoverage-img]: https://badgen.net/badge/coverage/100%25/green?icon=codecov&cache=300 |
| 245 | + |
| 246 | +[codecoverage-url]: https://codecov.io/gh/tunnckoCore/opensource |
| 247 | + |
| 248 | +[codestyle-url]: https://github.com/airbnb/javascript |
| 249 | +[codestyle-img]: https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb&cache=300 |
| 250 | + |
| 251 | +[linuxbuild-url]: https://github.com/tunnckocore/opensource/actions |
| 252 | +[linuxbuild-img]: https://badgen.net/github/checks/tunnckoCore/opensource/master?cache=300&label=build&icon=github |
| 253 | + |
| 254 | +[ccommits-url]: https://conventionalcommits.org/ |
| 255 | +[ccommits-img]: https://badgen.net/badge/conventional%20commits/v1.0.0/green?cache=300 |
| 256 | + |
| 257 | +[standard-release-url]: https://github.com/standard-release/standard-release |
| 258 | +[standard-release-img]: https://badgen.net/badge/semantically/released/05c5ff?cache=300 |
| 259 | + |
| 260 | +[community-img]: https://badgen.net/badge/join/community/7b16ff?cache=300 |
| 261 | +[community-url]: https://github.com/tunnckocorehq/community |
| 262 | + |
| 263 | +[last-commit-img]: https://badgen.net/github/last-commit/tunnckoCore/opensource/master?cache=300 |
| 264 | +[last-commit-url]: https://github.com/tunnckoCore/opensource/commits/master |
| 265 | + |
| 266 | +[nodejs-img]: https://badgen.net/badge/node/>=10.13/green?cache=300 |
| 267 | + |
| 268 | +[downloads-weekly-img]: https://badgen.net/npm/dw/to-file-path?icon=npm&cache=300 |
| 269 | +[downloads-monthly-img]: https://badgen.net/npm/dm/to-file-path?icon=npm&cache=300 |
| 270 | +[downloads-total-img]: https://badgen.net/npm/dt/to-file-path?icon=npm&cache=300 |
| 271 | + |
| 272 | +[renovateapp-url]: https://renovatebot.com |
| 273 | +[renovateapp-img]: https://badgen.net/badge/renovate/enabled/green?cache=300 |
| 274 | + |
| 275 | +[prs-welcome-img]: https://badgen.net/badge/PRs/welcome/green?cache=300 |
| 276 | +[prs-welcome-url]: http://makeapullrequest.com |
| 277 | + |
| 278 | +<!-- TODO: update icon --> |
| 279 | + |
| 280 | +[paypal-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HYJJEZNSGAPGC&source=url |
| 281 | +[paypal-img]: https://badgen.net/badge/PayPal/donate/003087?cache=300&icon=https://simpleicons.now.sh/paypal/fff |
| 282 | + |
| 283 | +<!-- TODO: update icon --> |
| 284 | + |
| 285 | +[kofi-url]: https://ko-fi.com/tunnckoCore |
| 286 | +[kofi-img]: https://badgen.net/badge/Buy%20me/a%20coffee/29abe0c2?cache=300&icon=https://rawcdn.githack.com/tunnckoCore/badgen-icons/f8264c6414e0bec449dd86f2241d50a9b89a1203/icons/kofi.svg |
| 287 | + |
| 288 | +<!-- TODO: update icon --> |
| 289 | + |
| 290 | +[bitcoin-url]: https://www.blockchain.com/btc/payment_request?address=3QNHKun1K1SUui1b4Z3KEGPPsWC1TgtnqA&message=Open+Source+Software&amount_local=10¤cy=USD |
| 291 | +[bitcoin-img]: https://badgen.net/badge/Bitcoin%20tip/3QNHKun...b4Z3KEGPPsWC1TgtnqA/yellow?cache=300&icon=https://simpleicons.now.sh/bitcoin/fff |
| 292 | +[keybase-url]: https://keybase.io/tunnckoCore |
| 293 | +[keybase-img]: https://badgen.net/keybase/pgp/tunnckoCore?cache=300 |
| 294 | +[twitter-url]: https://twitter.com/tunnckoCore |
| 295 | +[twitter-img]: https://badgen.net/twitter/follow/tunnckoCore?icon=twitter&color=1da1f2&cache=300 |
| 296 | +[patreon-url]: https://www.patreon.com/bePatron?u=5579781 |
| 297 | +[patreon-img]: https://badgen.net/badge/Become/a%20patron/F96854?icon=patreon |
| 298 | + |
| 299 | +<!-- [patreon-img]: https://badgen.net/badge/Patreon/tunnckoCore/F96854?icon=patreon --> |
| 300 | + |
| 301 | +[patreon-sponsor-img]: https://badgen.net/badge/become/a%20sponsor/F96854?icon=patreon |
| 302 | +[twitter-share-url]: https://twitter.com/intent/tweet?text=https://ghub.now.sh/to-file-path&via=tunnckoCore |
| 303 | +[twitter-share-img]: https://badgen.net/badge/twitter/share/1da1f2?icon=twitter |
| 304 | +[open-issue-url]: https://github.com/tunnckoCore/opensource/issues/new |
| 305 | +[tunnckocore_legal]: https://badgen.net/https/liam-badge-daknys6gadky.runkit.sh/com/legal/tunnckocore?label&color=A56016&icon=https://svgshare.com/i/Dt6.svg |
| 306 | +[tunnckocore_consulting]: https://badgen.net/https/liam-badge-daknys6gadky.runkit.sh/com/consulting/tunnckocore?label&color=07ba96&icon=https://svgshare.com/i/Dt6.svg |
| 307 | +[tunnckocore_security]: https://badgen.net/https/liam-badge-daknys6gadky.runkit.sh/com/security/tunnckocore?label&color=ed1848&icon=https://svgshare.com/i/Dt6.svg |
| 308 | +[tunnckocore_opensource]: https://badgen.net/https/liam-badge-daknys6gadky.runkit.sh/com/opensource/tunnckocore?label&color=ff7a2f&icon=https://svgshare.com/i/Dt6.svg |
| 309 | +[tunnckocore_newsletter]: https://badgen.net/https/liam-badge-daknys6gadky.runkit.sh/com/newsletter/tunnckocore?label&color=5199FF&icon=https://svgshare.com/i/Dt6.svg |
| 310 | + |
| 311 | +<!-- prettier-ignore-end --> |
| 312 | + |
| 313 | +[fn-name]: https://github.com/sindresorhus/fn-name |
| 314 | +[ip-filter]: https://github.com/tunnckocore/ip-filter |
| 315 | +[is-match]: https://github.com/jonschlinkert/is-match |
| 316 | +[koa]: https://github.com/koajs/koa |
| 317 | +[micromatch]: https://github.com/micromatch/micromatch |
0 commit comments