https://github.com/manovotny/chance-path
A Chance.js mixin to generate paths.
https://github.com/manovotny/chance-path
chance chancejs mixin path
Last synced: about 2 months ago
JSON representation
A Chance.js mixin to generate paths.
- Host: GitHub
- URL: https://github.com/manovotny/chance-path
- Owner: manovotny
- License: mit
- Created: 2017-04-15T17:42:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-08T21:21:42.000Z (over 5 years ago)
- Last Synced: 2025-03-01T08:24:26.299Z (2 months ago)
- Topics: chance, chancejs, mixin, path
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chance-path
> A [Chance.js mixin](http://chancejs.com/#mixin) to generate paths.
## Install
### NPM
```
$ npm i chance-path
```### Yarn
```
$ yarn add chance-path
```## Usage
```js
import Chance from 'chance';
import path from 'chance-path';const chance = new Chance();
chance.mixin({
path
});chance.path();
```By default, `chance-path` will return a randomly generated path.
Example: `some/random/path/to/something/somewhere/some.file`
### Options
Below is a list of available configuration options that you can pass into `chance-path`.
```js
chance.path({
// options
});
```#### depth
Specifies how deep the path is.
For example, `chance.path({depth: 4})` would produce something like `path/depth/of/four/random.random`.
> Defaults to [`chance.d6()`](http://chancejs.com/#dice).
#### ext
Specifies what the file extension is.
For example, `chance.path({ext: '.custom'})` would produce something like `random/random/random.custom`.
> Defaults to [`chance.word()`](http://chancejs.com/#word).
#### name
Specifies what the file name is.
For example, `chance.path({name: 'custom'})` would produce something like `random/random/custom.random`.
> Defaults to [`chance.word()`](http://chancejs.com/#word).
#### root
Specifies if the path should be a root path.
For example, `chance.path({root: true})` would produce something like `/random/random/random.random`.
> Defaults to [`chance.bool()`](http://chancejs.com/#bool).
## License
MIT © [Michael Novotny](https://manovotny.com)