@util.js/privates
v0.41.3
Published
JavaScript utility class for private member variables
Downloads
13
Maintainers
Readme
@util.js/privates
JavaScript utility class for private member variables
@util.js/privates is part of Util.js.
Privates
Kind: global class
Access: public
new Privates()
JavaScript utility class for private member variables.
This class decreases some of the boilerplate of the WeakMap pattern as described by "Private Variables in JavaScript with ES6 WeakMaps" and "Privates In ES2015 Javascript Classes". This utility handles shallow copying at construction.
Private fields may become a part of the ECMA standard. The following is a StackOverflow answer to the question "Private properties in JavaScript ES6 classes": "Private fields are being implemented in the ECMA standard. You can start using them today with babel 7 and stage 3 preset." Wouldn't private fields make this class obsolete? Not necessarily. If each of your privates is a function (e.g., you want to lazy load all member variables), this class has convenience methods for that.
privates.call()
Calls this.get(thiz, property)()
.
Kind: instance method of Privates
Access: public