D
Property descriptor factory
Originally derived from es5-ext package.
Defining properties with descriptors is very verbose:
var {};Object;
D cuts that to:
var d = ; var {};Object;
By default, created descriptor follow characteristics of native ES5 properties, and defines values as:
configurable: true enumerable: false writable: true
You can overwrite it by preceding value argument with instruction:
; // { configurable: true, enumerable: false, writable: false }; // { configurable: true, enumerable: true, writable: false }; // { configurable: false, enumerable: true, writable: false } // Same way for get/set:d; // { configurable: false, enumerable: true }
Installation
$ npm install d
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack
Other utilities
autoBind(obj, props) (d/auto-bind)
Define methods which will be automatically bound to its instances
var d = ;var autoBind = ; var { this_count = 0; };Object; var foo = ; // Increment foo counter on each domEl clickdomEl;
lazy(obj, props) (d/lazy)
Define lazy properties, which will be resolved on first access
var d = ;var lazy = ; var {};Object; var foo = ;fooitems; // foo.items array created and defined directly on foo
$ npm test
Security contact information
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.