canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS and CSS.
74 lines (73 loc) • 4.42 kB
JSON
{
"_args": [
[
"d@https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"/Users/gajus/Documents/dev/canonical-code-style/canonical"
]
],
"_from": "d@>=0.1.1 <0.2.0",
"_id": "d@0.1.1",
"_inCache": true,
"_location": "/d",
"_phantomChildren": {},
"_requested": {
"name": "d",
"raw": "d@https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"rawSpec": "https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"scope": null,
"spec": "https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"type": "remote"
},
"_requiredBy": [
"/es6-iterator",
"/es6-map",
"/es6-set",
"/es6-symbol",
"/es6-weak-map",
"/event-emitter"
],
"_resolved": "https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"_shasum": "da184c535d18d8ee7ba2aa229b914009fae11309",
"_shrinkwrap": null,
"_spec": "d@https://registry.npmjs.org/d/-/d-0.1.1.tgz",
"_where": "/Users/gajus/Documents/dev/canonical-code-style/canonical",
"author": {
"email": "medyk@medikoo.com",
"name": "Mariusz Nowak",
"url": "http://www.medikoo.com/"
},
"bugs": {
"url": "https://github.com/medikoo/d/issues"
},
"dependencies": {
"es5-ext": "~0.10.2"
},
"description": "Property descriptor factory",
"devDependencies": {
"tad": "~0.1.21"
},
"homepage": "https://github.com/medikoo/d#readme",
"keywords": [
"descriptor",
"descriptors",
"ecma",
"ecmascript",
"es",
"meta",
"properties",
"property"
],
"license": "MIT",
"name": "d",
"optionalDependencies": {},
"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 [](https://travis-ci.org/medikoo/d)\n\n\t$ npm test\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git://github.com/medikoo/d.git"
},
"scripts": {
"test": "node node_modules/tad/bin/tad"
},
"version": "0.1.1"
}