https://github.com/valueof/ministruct
Small lib to define strictly typed objects
https://github.com/valueof/ministruct
Last synced: about 1 year ago
JSON representation
Small lib to define strictly typed objects
- Host: GitHub
- URL: https://github.com/valueof/ministruct
- Owner: valueof
- License: bsd-2-clause
- Created: 2013-07-17T22:15:15.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-01-06T00:59:54.000Z (over 12 years ago)
- Last Synced: 2023-12-23T11:02:19.248Z (over 2 years ago)
- Language: JavaScript
- Size: 146 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ministruct
==========
[](http://travis-ci.org/antonkovalyov/ministruct)
Small library to define strictly typed objects. Example:
```javascript
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.