Objects with dynamic attributes


Dynobj implements a new class of objects that support dynamic get and set functions for dynamic attributes (similar to languages like Python).


var DynObj = new (require('dynobj').DynObj)()
var MyCoolClass = DynObj.create()
MyCoolClass.prototype.__get__ = function(key) {
    return 'cool '+key

MyCoolClass.prototype.set = function(key, val) { if (key === 'allowed') return true // default behaviour

// returning anything other that true will suppress the default behaviour and allows you you override
console.log('someone tried to set '+key)
return false


As described in LICENSE