model-golem
A model factory JS library to generate data mocks
Installing
npm install --save-dev model-golem
Using
Load the Factory:
var Factory = require('model-golem');
import Factory from 'model-golem';
Define a model:
var Person = {
id: function() {
return this.sequence;
},
name: '',
charisma: 42,
username: function() {
return this.item.name.toLowerCase().replace(/ /g, '');
}
};
Instantiate the Factory with your model:
var peopleFactory = new Factory(Person);
Create your mocks!
var person = peopleFactory({
name: 'Leo Balter',
});
Create your mocks from arrays!
var people = peopleFactory([
{
name: 'Green Avocados',
charisma: 0
},
{
name: 'Spicy Mustard',
id: 100,
charisma: 37,
username: 'mryellow'
}
]);
Get the stored data!
var stored = peopleFactory.store;
MIT Licensed