2.0.5 • Published 4 years ago

mimeo-js v2.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Mimic sample data.

Migration to v2

See Functions

Usage

const mimic = require('mimeo-js').mimic;
const sampleData = {
    name: 'John Doe',
    gender: (chance) => chance.pickone(['male','female']);
}

console.log(mimic(sampleData)); // Different each time
console.log(mimic(sampleData, true)); // Will always be same whenever ran
console.log(mimic(sampleData, {seed: 'someSeed')); // Will always be same whenever ran using same seed

Args

  • data {any}

    The data to be mimicked. Tries to get an approximately similar data item.

Objects

Objects have each key recursively called.

Functions

If the data value is a function, it is called with one parameter, a chance instance. The mimicked value will be the return value of the function:

  • opts {shouldSeed | generatorOpts}

    Is either a boolean (shouldSeed) or an object(generatorOpts). See below.

    shouldSeed {boolean}

    You can get repeatable values by passing true as the second parameter of the mimic function

    generatorOpts {object}
    {
       seed {any}: The seed that will be used.
    }
2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.2.2

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago