lodash-decorators
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -41,3 +41,3 @@ 'use strict'; | ||
if ((0, _lodash.isFunction)(_descriptor.value)) { | ||
if ((0, _lodash.isFunction)(_descriptor.value) || (0, _lodash.isFunction)(_descriptor.get)) { | ||
Object.defineProperty(target.prototype, key, bindMethod(target, key, _descriptor)); | ||
@@ -49,8 +49,2 @@ } | ||
function checkBindValue(value) { | ||
if (!(0, _lodash.isFunction)(value)) { | ||
throw new Error('Binds can not be used on getters, setters, or properties'); | ||
} | ||
} | ||
function bindMethod(target, name, descriptor) { | ||
@@ -74,13 +68,11 @@ for (var _len4 = arguments.length, args = Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) { | ||
checkBindValue(thisValue); | ||
var boundValue = (0, _lodash.isFunction)(thisValue) ? _lodash.bind.apply(undefined, [thisValue, this].concat(args)) : thisValue; | ||
var boundFn = _lodash.bind.apply(undefined, [thisValue, this].concat(args)); | ||
Object.defineProperty(this, name, { | ||
writable: writable, | ||
configurable: true, | ||
value: boundFn | ||
value: boundValue | ||
}); | ||
return boundFn; | ||
return boundValue; | ||
} | ||
@@ -87,0 +79,0 @@ }; |
@@ -1,2 +0,4 @@ | ||
require('babel/register')(); | ||
require('babel/register')({ | ||
optional: ['es7.decorators'] | ||
}); | ||
require('./gulp'); |
{ | ||
"name": "lodash-decorators", | ||
"author": "Steven Sojka", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=0.12.0" |
@@ -17,3 +17,3 @@ 'use strict'; | ||
if (isFunction(descriptor.value)) { | ||
if (isFunction(descriptor.value) || isFunction(descriptor.get)) { | ||
Object.defineProperty(target.prototype, key, bindMethod(target, key, descriptor)); | ||
@@ -25,8 +25,2 @@ } | ||
function checkBindValue(value) { | ||
if (!isFunction(value)) { | ||
throw new Error('Binds can not be used on getters, setters, or properties'); | ||
} | ||
} | ||
function bindMethod(target, name, descriptor, ...args) { | ||
@@ -44,15 +38,13 @@ const { value, get, writable } = descriptor; | ||
checkBindValue(thisValue); | ||
let boundValue = isFunction(thisValue) ? bind(thisValue, this, ...args) : thisValue; | ||
let boundFn = bind(thisValue, this, ...args); | ||
Object.defineProperty(this, name, { | ||
writable, | ||
configurable: true, | ||
value: boundFn | ||
value: boundValue | ||
}); | ||
return boundFn; | ||
return boundValue; | ||
} | ||
} | ||
} |
31508
683