🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

dynobj

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynobj

Objects with dynamic attributes

latest
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

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

Keywords

dynamic attributes

FAQs

Package last updated on 10 Aug 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts