Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into sprint-2018Q1S4
- Loading branch information
Showing
998 changed files
with
27,987 additions
and
698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@root | ||
|
||
module | ||
|
||
tabs | ||
indent 2 | ||
maxlen 100 | ||
|
||
ass | ||
nomen | ||
plusplus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
/node_modules | ||
/npm-debug.log | ||
/.lintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
language: node_js | ||
node_js: | ||
- 0.12 | ||
- 4 | ||
- 5 | ||
|
||
before_install: | ||
- mkdir node_modules; ln -s ../ node_modules/d | ||
|
||
notifications: | ||
email: | ||
- medikoo+d@medikoo.com | ||
|
||
script: "npm test && npm run lint" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
v1.0.0 -- 2015.12.04 | ||
- autoBind changes: | ||
- replace `bindTo` argument with options and `resolveContext` option | ||
- Add support `overwriteDefinition` | ||
- Introduce IE11 bug workaround in `lazy` handler | ||
|
||
v0.1.1 -- 2014.04.24 | ||
- Add `autoBind` and `lazy` utilities | ||
- Allow to pass other options to be merged onto created descriptor. | ||
Useful when used with other custom utilties | ||
|
||
v0.1.0 -- 2013.06.20 | ||
Initial (derived from es5-ext project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# 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 }, | ||
withdraw: { 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 () { | ||
/* ... */ | ||
}), | ||
withdraw: 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 } | ||
``` | ||
|
||
### 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](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) | ||
|
||
### 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; }; | ||
Object.defineProperties(Foo.prototype, autoBind({ | ||
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 () {}; | ||
Object.defineProperties(Foo.prototype, lazy({ | ||
items: d(function () { return []; }) | ||
})); | ||
|
||
var foo = new Foo(); | ||
foo.items.push(1, 2); // foo.items array created and defined directly on foo | ||
``` | ||
|
||
## Tests [![Build Status](https://travis-ci.org/medikoo/d.png)](https://travis-ci.org/medikoo/d) | ||
|
||
$ npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
var copy = require('es5-ext/object/copy') | ||
, normalizeOptions = require('es5-ext/object/normalize-options') | ||
, ensureCallable = require('es5-ext/object/valid-callable') | ||
, map = require('es5-ext/object/map') | ||
, callable = require('es5-ext/object/valid-callable') | ||
, validValue = require('es5-ext/object/valid-value') | ||
|
||
, bind = Function.prototype.bind, defineProperty = Object.defineProperty | ||
, hasOwnProperty = Object.prototype.hasOwnProperty | ||
, define; | ||
|
||
define = function (name, desc, options) { | ||
var value = validValue(desc) && callable(desc.value), dgs; | ||
dgs = copy(desc); | ||
delete dgs.writable; | ||
delete dgs.value; | ||
dgs.get = function () { | ||
if (!options.overwriteDefinition && hasOwnProperty.call(this, name)) return value; | ||
desc.value = bind.call(value, options.resolveContext ? options.resolveContext(this) : this); | ||
defineProperty(this, name, desc); | ||
return this[name]; | ||
}; | ||
return dgs; | ||
}; | ||
|
||
module.exports = function (props/*, options*/) { | ||
var options = normalizeOptions(arguments[1]); | ||
if (options.resolveContext != null) ensureCallable(options.resolveContext); | ||
return map(props, function (desc, name) { return define(name, desc, options); }); | ||
}; |
Oops, something went wrong.