immutable-struct
package for creating immutable models, specifically for upholding api contracts (think DTO)
Last updated 4 years ago by chemdrew .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install immutable-struct 
SYNC missed versions from official npm registry.

Build Status Coverage Status

here is how you use it

var obj = {
    string: {type: 'string' },
    number: {type: 'number'},
    boolean: {type: 'boolean'},
    enum: {type: 'string', values: ['TEST1', 'TEST2', 'TEST3']},
    array: {type: 'array:string', values: ['test1', 'test2']},
    object: {type: 'object', instanceOf: ParentModel}
}

var Obj = model.create(obj);

var myObj = newObj();

myObj.setNumber(10);
myObj.getNumber(); // returns 10

// or
var myObj = newObj( {string: 'stringInit', number: 20, boolean: false} );

ideally you would have each model in it's own file with module.exports = model.create(obj)

Current Tags

  • 0.1.0                                ...           latest (4 years ago)

1 Versions

  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |