dynobj

0.0.4 • Public • Published

Dynobj

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

Usage:


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
}

License

As described in LICENSE

Readme

Keywords

none

Package Sidebar

Install

npm i dynobj

Weekly Downloads

3

Version

0.0.4

License

none

Last publish

Collaborators

  • ckudige