0.0.3 • Published 6 years ago

faker-structures v0.0.3

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Faker Structures

Compose data structures with fake data from faker.js. Similar to custom generators from boo1ean/casual.

$ npm install --save-dev faker faker-structures

.collection(shape)(length)

Generate an array of objects.

import faker from 'faker'
import { collection } from 'faker-structures'

// define the structure
const userCollection = collection({
  id: faker.random.number,
  name: () => `${faker.name.firstName} ${faker.name.lastName}`
})

// generate a collection with three users
userCollection(3)

.record(key, structure)(length)

Generates an object of objects.

import faker from 'faker'
import { record } from 'faker-structures'

// define the structure
const userRecord = record(faker.random.number, {
  firstName: faker.name.firstName,
  lastName: faker.name.lastName
})

// generate a record object with three users
userRecord(3)