// Generate random data from a object
var mocked = yod({
"a": "a",
"n": 3,
"child": {
"ca": "c @Parent.a",
"cb": "@Self.ca@Self.ca"
},
"modifier": "@Self.a.replace('a', 'hack')",
"execScript": "` 2 + 1 `",
"@Self.child.ca": "hack object key"
});
console.log(mocked);
// Create custom type -- User
yod.type('User', {
name: 'David',
age: 20,
hello: 'Hello @Self.name'
});
// Generate random data from custom type
console.log(yod('@User'));
// Create a modifier -- repeat
yod.modifier(':repeat', function(genFn, len) {
var length = len || yod._.random(1, 10);
return yod._.times(length, genFn);
});
// Use modifier on type
console.log(yod('@User.repeat(3)'));