forked from panaverse/learn-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
44 lines (44 loc) · 3.53 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{
"name": "d",
"version": "0.1.1",
"description": "Property descriptor factory",
"author": {
"name": "Mariusz Nowak",
"email": "medyk@medikoo.com",
"url": "http://www.medikoo.com/"
},
"scripts": {
"test": "node node_modules/tad/bin/tad"
},
"repository": {
"type": "git",
"url": "git://github.com/medikoo/d.git"
},
"keywords": [
"descriptor",
"es",
"ecmascript",
"ecma",
"property",
"descriptors",
"meta",
"properties"
],
"dependencies": {
"es5-ext": "~0.10.2"
},
"devDependencies": {
"tad": "~0.1.21"
},
"license": "MIT",
"readme": "# D - Property descriptor factory\n\n_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._\n\nDefining properties with descriptors is very verbose:\n\n```javascript\nvar Account = function () {};\nObject.defineProperties(Account.prototype, {\n deposit: { value: function () {\n /* ... */\n }, configurable: true, enumerable: false, writable: true },\n whithdraw: { value: function () {\n /* ... */\n }, configurable: true, enumerable: false, writable: true },\n balance: { get: function () {\n /* ... */\n }, configurable: true, enumerable: false }\n});\n```\n\nD cuts that to:\n\n```javascript\nvar d = require('d');\n\nvar Account = function () {};\nObject.defineProperties(Account.prototype, {\n deposit: d(function () {\n /* ... */\n }),\n whithdraw: d(function () {\n /* ... */\n }),\n balance: d.gs(function () {\n /* ... */\n })\n});\n```\n\nBy default, created descriptor follow characteristics of native ES5 properties, and defines values as:\n\n```javascript\n{ configurable: true, enumerable: false, writable: true }\n```\n\nYou can overwrite it by preceding _value_ argument with instruction:\n```javascript\nd('c', value); // { configurable: true, enumerable: false, writable: false }\nd('ce', value); // { configurable: true, enumerable: true, writable: false }\nd('e', value); // { configurable: false, enumerable: true, writable: false }\n\n// Same way for get/set:\nd.gs('e', value); // { configurable: false, enumerable: true }\n```\n\n### Other utilities\n\n#### autoBind(obj, props) _(d/auto-bind)_\n\nDefine methods which will be automatically bound to its instances\n\n```javascript\nvar d = require('d');\nvar autoBind = require('d/auto-bind');\n\nvar Foo = function () { this._count = 0; };\nautoBind(Foo.prototype, {\n increment: d(function () { ++this._count; });\n});\n\nvar foo = new Foo();\n\n// Increment foo counter on each domEl click\ndomEl.addEventListener('click', foo.increment, false);\n```\n\n#### lazy(obj, props) _(d/lazy)_\n\nDefine lazy properties, which will be resolved on first access\n\n```javascript\nvar d = require('d');\nvar lazy = require('d/lazy');\n\nvar Foo = function () {};\nlazy(Foo.prototype, {\n items: d(function () { return []; })\n});\n\nvar foo = new Foo();\nfoo.items.push(1, 2); // foo.items array created\n```\n\n## Installation\n### NPM\n\nIn your project path:\n\n\t$ npm install d\n\n### Browser\n\nYou can easily bundle _D_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake)\n\n## Tests [![Build Status](https://travis-ci.org/medikoo/d.png)](https://travis-ci.org/medikoo/d)\n\n\t$ npm test\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/medikoo/d/issues"
},
"homepage": "https://github.com/medikoo/d#readme",
"_id": "d@0.1.1",
"_shasum": "da184c535d18d8ee7ba2aa229b914009fae11309",
"_resolved": "https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"_from": "d@>=0.1.1 <0.2.0"
}