Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/manovotny/chance-object

A Chance.js mixin to generate objects.
https://github.com/manovotny/chance-object

chance chancejs mixin object

Last synced: 12 days ago
JSON representation

A Chance.js mixin to generate objects.

Awesome Lists containing this project

README

        

# chance-object

> A [Chance.js mixin](http://chancejs.com/#mixin) to generate objects.

## Install

### NPM

```
$ npm i chance-object
```

### Yarn

```
$ yarn add chance-object
```

## Usage

```js
import Chance from 'chance';
import object from 'chance-object';

const chance = new Chance();

chance.mixin({
object
});

chance.object();
```

By default, `chance-object` will return a randomly generated object.

Example:

```js
{
randomKey: 'randomValue';
}
```

`chance-object` can also take an optional object as a parameter, which will create a randomly generated object and merge it with the supplied object.

Example:

```js
chance.object({
key: 'value'
});
```

Result:

```js
{
randomKey: 'randomValue',
key: 'value'
}
```

## License

MIT © [Michael Novotny](https://manovotny.com)