/JSONFactory

Simple way to build objects for testing.

Primary LanguageJavaScript

Easily create various states of an object without having to redefine the entire object.

JSONFactory.define('User', {
    'id': 1,
    'name': 'Alice',
    'age': 22,
    'posts': [],
    'comments': []
});

console.log(JSONFactory.build('User'));
console.log(JSONFactory.build('User', {
    'id': 2,
    'name': 'Bob'
}));

// Result
{ id: 1, name: 'Alice', age: 22, posts: [], comments: [] }
{ id: 2, name: 'Bob', age: 22, posts: [], comments: [] }