lodash-decorators
Advanced tools
Comparing version 0.3.0 to 0.4.0
26
bind.js
@@ -18,2 +18,6 @@ 'use strict'; | ||
var _bindAll = require('./bindAll'); | ||
var _bindAll2 = _interopRequireDefault(_bindAll); | ||
var _Applicator = require('./Applicator'); | ||
@@ -33,9 +37,7 @@ | ||
return properties.length === 1 ? bindClass.apply(undefined, properties.concat(args)) : bindMethod.apply(undefined, properties.concat(args)); | ||
return properties.length === 1 ? _bindAll2['default'].apply(undefined, args).apply(undefined, properties) : bindMethod.apply(undefined, properties.concat(args)); | ||
}; | ||
} | ||
; | ||
function bindClass(target, name, descriptor) { | ||
function bindMethod(target, name, descriptor) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) { | ||
@@ -45,18 +47,2 @@ args[_key3 - 3] = arguments[_key3]; | ||
var keys = Reflect.ownKeys(target.prototype).forEach(function (key) { | ||
if (key !== 'constructor') { | ||
var _descriptor = Object.getOwnPropertyDescriptor(target.prototype, key); | ||
if ((0, _lodashLangIsFunction2['default'])(_descriptor.value) || (0, _lodashLangIsFunction2['default'])(_descriptor.get)) { | ||
Object.defineProperty(target.prototype, key, bindMethod(target, key, _descriptor)); | ||
} | ||
} | ||
}); | ||
} | ||
function bindMethod(target, name, descriptor) { | ||
for (var _len4 = arguments.length, args = Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) { | ||
args[_key4 - 3] = arguments[_key4]; | ||
} | ||
var value = descriptor.value; | ||
@@ -63,0 +49,0 @@ var _get = descriptor.get; |
@@ -65,3 +65,3 @@ 'use strict'; | ||
}; | ||
}; | ||
} | ||
} | ||
@@ -111,5 +111,5 @@ | ||
return fn.apply(this, methodArgs); | ||
}; | ||
} | ||
}; | ||
}; | ||
} | ||
} |
@@ -29,2 +29,6 @@ 'use strict'; | ||
var _bindAll = require('./bindAll'); | ||
var _bindAll2 = _interopRequireDefault(_bindAll); | ||
var _decoratorFactory = require('./decoratorFactory'); | ||
@@ -69,3 +73,4 @@ | ||
bind: _bind2['default'], | ||
tap: _tap2['default'] | ||
tap: _tap2['default'], | ||
bindAll: _bindAll2['default'] | ||
}); | ||
@@ -72,0 +77,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A collection of decorators using lodash at it's core.", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"engines": { | ||
@@ -26,2 +26,4 @@ "node": ">=0.12.0" | ||
"devDependencies": { | ||
"babel": "~5.0.9", | ||
"babel-eslint": "^3.1.20", | ||
"chai": "~2.2.0", | ||
@@ -33,2 +35,4 @@ "chalk": "~1.0.0", | ||
"gulp-chmod": "~1.2.0", | ||
"gulp-eslint": "^0.14.0", | ||
"gulp-if": "^1.2.5", | ||
"gulp-jshint": "~1.10.0", | ||
@@ -42,4 +46,3 @@ "gulp-mocha": "~2.0.1", | ||
"sinon-chai": "~2.7.0", | ||
"yargs": "~3.6.0", | ||
"babel": "~5.0.9" | ||
"yargs": "^3.14.0" | ||
}, | ||
@@ -46,0 +49,0 @@ "dependencies": { |
@@ -63,2 +63,3 @@ # lodash-decorators | ||
- `bind` | ||
- `bindAll` | ||
- `modArgs` | ||
@@ -256,2 +257,6 @@ | ||
__Known Issue__: When using bind on a single method the bind decorator MUST come last | ||
in the chain of decorators. There is no graceful solution for this currently. You can always | ||
use `@bindAll('fn')` on the class and only include the functions you want to include. | ||
#### Example | ||
@@ -286,4 +291,7 @@ | ||
You can also bind entire classes. | ||
You can also bind entire classes with `bindAll` or `bind`. | ||
__Note__: Using `@bind()` on a class delegates to the `@bindAll()` implemenation. | ||
#### Example | ||
@@ -294,3 +302,3 @@ | ||
@bind() | ||
@bindAll() | ||
class Person { | ||
@@ -297,0 +305,0 @@ constructor(firstName, lastName) { |
36237
22
605
331
19