Miss any of our Open RFC calls?Watch the recordings here! »

@util.js/privates

0.39.2 • Public • Published

@util.js/privates

JavaScript utility class for private member variables

NPM Status Travis CI Build Status

@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

Install

npm i @util.js/privates

DownloadsWeekly Downloads

18

Version

0.39.2

License

MIT

Unpacked Size

23.9 kB

Total Files

7

Last publish

Collaborators

  • avatar