ministruct

Small library to define strictly typed objects


Keywords
struct, types
License
BSD-3-Clause
Install
npm install ministruct@0.0.2

Documentation

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.