mockuments

0.0.3 • Public • Published

Mockuments

Mock JSON Documents with funny defaults.

Formerly Socuments.

carbon

Usage

mockuments ([ count, template ])

  • count: <Number>
    the number of mockuments to generate, defaulting to 10.

  • template: <Object>
    a mockuments template. See templates for more information on creating a custom template.

  • returns: <Array>
    An array of mockuments.

const mocks = require("mockuments")();
 
const mocks100 = require("mockuments")(100);
 
const template = {
  firstName: { type: "name", length: "random" },
  lastName: { type: "name", length: 10 },
  lastLogin: { type: "date" },
  email: { type: "email" },
  loggedIn: { type: "boolean" },
};
const customMocks = require("mockuments")(10, template);

Templates

To use your own template to generate Mockuments, simply supply a template object. Templates require a particular structure, requiring atleast a type field. Mockuments support some custom types along with many of the JS types.

Default template

{
  first: { type: 'name', max: 'rand' },
  middle: { type: 'letter', caps: true },
  last: { type: 'name', max: 'rand' },
  bio: {
    height: { type: 'height', max: 8 },
    age: { type: 'age', max: 100 },
    race: { type: 'race' },
    prey: { type: 'race' },
    bloodtype: { type: "choose", vals: [ "A", "...", "Unknown" ] },
    notes: { type: 'array', length: 'rand', content: 'lorem' }
  },
  contact: {
    onEarth: { type: 'boolean' },
    mobile: { type: 'phone' },
    email: { type: 'email' },
    password: { type: 'base64' },
    uuid: { type: 'uuid' },
    aliases: { type: 'array', length: 'rand', content: 'uuid' }
  },
  lastLogin: { type: 'date' },
  generatedBy: { type: 'passthrough', pass: 'npm:mockuments' }
}
 

Readme

Keywords

Package Sidebar

Install

npm i mockuments

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

11 kB

Total Files

4

Last publish

Collaborators

  • msterpka