factorify
Better object factories.
Installation
Install with component(1):
$ component install mikanda/factorify
Usage
var factory = ; // build factory var User = ; // build object using factory var object = ;console; // -> 'generated random name'
API
Factory#sequence(name, [prefix])
Makes this attribute a sequence number. Optional prefix
is
prepended to the number.
Factory#attr(name, fn)
Defines a new attribute for which the value is calculated using
fn
.
Object([defs])
Initialize new object. defs
is an optional map to override
attributes.
var User = ;var user = name: 'my-other-name' ;console // -> 'my-other-name'
License
MIT