ministruct

0.0.2 • Public • Published

ministruct

build status

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(person);
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.

Readme

Keywords

none

Package Sidebar

Install

npm i ministruct

Weekly Downloads

0

Version

0.0.2

License

BSD

Last publish

Collaborators

  • antonkovalyov