node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey ยป



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