node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »


Synths Build Status NPM version

Synths is a JavaScript library that synthesize properties with type, methods, operators and more.

Development is ongoing. Test documentation is available in docs/ or in


var synthesize = require('synths').synthesize;
var john = {
    name: synthesize(),
    age: synthesize('integer'),
    sex: synthesize({ constant: 'male' }),
    weight: synthesize({ default: 80 })
console.log(;           // 'John' 
console.log(john.age());            // 25 
console.log(;            // 'male' 
console.log(john.weight());         // 80 


  • Chainable setter'John').age(25)
  • Getter returns 'John'
  • Binary operator obj.prop('+', val) is equivalent to obj.prop() + val.
  • Assignment operator obj.prop('+=', val) is equivalent to obj.prop(obj.prop() + val).
  • Method of property obj.prop('#toString'), and aliases: obj.prop('#to string'), obj.prop('#to-string'), or obj.prop('#to_string'), are equivalent to obj.prop().toString().
  • Lodash method obj.prop('#forEach', getName) and aliases obj.prop('#for each', getName), obj.prop('#for-each', getName), or obj.prop('#for_each', getName) are equivalent to _.forEach(obj.prop(), getName).
  • Property's property obj.prop('subProp') and aliases: obj.prop('sub prop'), obj.prop('sub-prop')``obj.prop('sub_prop'), are equivalent to obj.prop().subProp(). Setter obj.prop('subProp', 123) is equivalent to obj.prop().subProp(123).
  • Property's key, obj.prop('key') is equivalent to obj.prop().key. Setter obj.prop('key', val) is equivalent to obj.prop().key = val.
  • Property's index obj.prop(1), equivalent to obj.prop()[1]. obj.prop(1, 'foo') is equivalent to obj.prop()[1] = 'foo'. Negative index: obj.prop(-1) is equivalent to obj.prop(obj.prop().length -1).

More details can be found in the aforementioned test documentation.