FakeJS is a module based on Chance to generate Data Model (Random) at runtime.
The model to create:
var child = {
id : 'hash',
name : 'first',
email : 'email',
birthday : 'birthday',
id : function(){
return 'US ' + Math.ceil(Math.random() * 1000);
},
fatherName: 'John Doe'
};
Using Fake.js
var fake = require('fake.js');
fake.create(child, 2, function(data){
console.log(data);
});
The result :
[
{
"id": "US 736",
"name": "Erick",
"email": "[email protected]",
"birthday": "Sun Jul 26 1942 00:00:00 GMT-0300 (BRT)",
"fatherName": "John Doe"
},
{
"id": "US 760",
"name": "Gabriel",
"email": "[email protected]",
"birthday": "Tue May 05 1953 00:00:00 GMT-0300 (BRT)",
"fatherName": "John Doe"
}
]
Fakejs accepts most parameters Chance available, in addition to the default properties of the javascript as String, Integer, boolean, and functions