Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Examples of how to use strict-object
// https://github.com/danielbeardsley/strict-object
// Create a new person type
var Person = StrictObject.define('name', 'age', 'country');
// Instatiate a Person
var pete = new Person();
// set properties using functions
pete.name('Peter');
// get properties using functions
console.log(pete.name());
// property setters return the target object and are thus chainable
pete.name('Peter')
.age(26)
.country('Uzbekistan');
// retrieve the properties as an object
console.log(pete._toObject()); // {name: 'Peter', age: 26, country: 'Uzbekistan'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment