summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/d/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/d/README.md')
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/d/README.md108
1 files changed, 108 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/d/README.md b/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/d/README.md
new file mode 100644
index 0000000000..872d493ed8
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/d/README.md
@@ -0,0 +1,108 @@
+# D - Property descriptor factory
+
+_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._
+
+Defining properties with descriptors is very verbose:
+
+```javascript
+var Account = function () {};
+Object.defineProperties(Account.prototype, {
+ deposit: { value: function () {
+ /* ... */
+ }, configurable: true, enumerable: false, writable: true },
+ whithdraw: { value: function () {
+ /* ... */
+ }, configurable: true, enumerable: false, writable: true },
+ balance: { get: function () {
+ /* ... */
+ }, configurable: true, enumerable: false }
+});
+```
+
+D cuts that to:
+
+```javascript
+var d = require('d');
+
+var Account = function () {};
+Object.defineProperties(Account.prototype, {
+ deposit: d(function () {
+ /* ... */
+ }),
+ whithdraw: d(function () {
+ /* ... */
+ }),
+ balance: d.gs(function () {
+ /* ... */
+ })
+});
+```
+
+By default, created descriptor follow characteristics of native ES5 properties, and defines values as:
+
+```javascript
+{ configurable: true, enumerable: false, writable: true }
+```
+
+You can overwrite it by preceding _value_ argument with instruction:
+```javascript
+d('c', value); // { configurable: true, enumerable: false, writable: false }
+d('ce', value); // { configurable: true, enumerable: true, writable: false }
+d('e', value); // { configurable: false, enumerable: true, writable: false }
+
+// Same way for get/set:
+d.gs('e', value); // { configurable: false, enumerable: true }
+```
+
+### Other utilities
+
+#### autoBind(obj, props) _(d/auto-bind)_
+
+Define methods which will be automatically bound to its instances
+
+```javascript
+var d = require('d');
+var autoBind = require('d/auto-bind');
+
+var Foo = function () { this._count = 0; };
+autoBind(Foo.prototype, {
+ increment: d(function () { ++this._count; });
+});
+
+var foo = new Foo();
+
+// Increment foo counter on each domEl click
+domEl.addEventListener('click', foo.increment, false);
+```
+
+#### lazy(obj, props) _(d/lazy)_
+
+Define lazy properties, which will be resolved on first access
+
+```javascript
+var d = require('d');
+var lazy = require('d/lazy');
+
+var Foo = function () {};
+lazy(Foo.prototype, {
+ items: d(function () { return []; })
+});
+
+var foo = new Foo();
+foo.items.push(1, 2); // foo.items array created
+```
+
+## Installation
+### NPM
+
+In your project path:
+
+ $ npm install d
+
+### Browser
+
+You can easily bundle _D_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake)
+
+## Tests [![Build Status](https://travis-ci.org/medikoo/d.png)](https://travis-ci.org/medikoo/d)
+
+ $ npm test