ministruct
v0.0.2
Published
Small library to define strictly typed objects
Downloads
3
Readme
ministruct
Small library to define strictly typed objects. Example:
var { struct, make, type } = require("ministruct");
var person = struct({
name: type.string,
age: type.number | type.nil,
nicks: type.array
});
var bob = make(sample);
bob.name = "Bob";
bob.age = 26;
bob.nicks = [ "bob1986", "sexybob" ];
console.log(bob.name); // Bob
bob.age = null; // OK
bob.nicks = null; // TypeError
Supported types: nil, array, object, number, string, func, regexp.