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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    1
  • 0.0.1
    2

Package Sidebar

Install

npm i ministruct

Weekly Downloads

3

Version

0.0.2

License

BSD

Last publish

Collaborators

  • antonkovalyov