lodash-decorators
Advanced tools
Comparing version 0.4.12 to 0.4.13
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _utilsLog = require('./utils/log'); | ||
var _utilsLog2 = _interopRequireDefault(_utilsLog); | ||
var applicators = { | ||
@@ -54,3 +58,3 @@ // Methods where the function is the last argument or the first | ||
return fn.apply(undefined, [Applicator.resolveFunction(args[0], this)].concat(_toConsumableArray(args.slice(1)))).apply(this, invokeArgs); | ||
return fn.apply(undefined, [Applicator.resolveFunction(args[0], this, target)].concat(_toConsumableArray(args.slice(1)))).apply(this, invokeArgs); | ||
}; | ||
@@ -67,3 +71,3 @@ }, | ||
return fn(Applicator.resolveFunction(fnName, this), value).apply(this, invokeArgs); | ||
return fn(Applicator.resolveFunction(fnName, this, target), value).apply(this, invokeArgs); | ||
}; | ||
@@ -94,3 +98,3 @@ }, | ||
return fn.apply(undefined, [value].concat(_toConsumableArray(args.map(function (method) { | ||
return Applicator.resolveFunction(method, _this); | ||
return Applicator.resolveFunction(method, _this, target); | ||
})))).apply(this, invokeArgs); | ||
@@ -141,10 +145,21 @@ }; | ||
/** | ||
* Resolves a function on the current target object. | ||
* Resolves a function on the current target object. It first will | ||
* try and resolve on the context object, then the target object, | ||
* then an error will be thrown if the method can not be resolved. | ||
* | ||
* @param {Function|String} method The method or method name. | ||
* @param {Object} [context] The context object to resolve from. | ||
* @param {Object} [target] The target object to resolve from. | ||
* @returns {Function} The resolved function. | ||
*/ | ||
resolveFunction: function resolveFunction(method, target) { | ||
return (0, _lodashLangIsFunction2['default'])(method) ? method : target[method]; | ||
resolveFunction: function resolveFunction(method, context, target) { | ||
if ((0, _lodashLangIsFunction2['default'])(method)) { | ||
return method; | ||
} else if ((0, _lodashLangIsFunction2['default'])(context[method])) { | ||
return context[method]; | ||
} else if ((0, _lodashLangIsFunction2['default'])(target[method])) { | ||
return target[method]; | ||
} | ||
throw new ReferenceError((0, _utilsLog2['default'])('Can not resolve method ' + method + ' on any target Objects')); | ||
} | ||
@@ -151,0 +166,0 @@ }; |
12
index.js
@@ -21,5 +21,5 @@ 'use strict'; | ||
var _bind = require('./bind'); | ||
var _bindBind = require('./bind/bind'); | ||
var _bind2 = _interopRequireDefault(_bind); | ||
var _bindBind2 = _interopRequireDefault(_bindBind); | ||
@@ -30,5 +30,5 @@ var _tap = require('./tap'); | ||
var _bindAll = require('./bindAll'); | ||
var _bindBindAll = require('./bind/bindAll'); | ||
var _bindAll2 = _interopRequireDefault(_bindAll); | ||
var _bindBindAll2 = _interopRequireDefault(_bindBindAll); | ||
@@ -73,5 +73,5 @@ var _decoratorFactory = require('./decoratorFactory'); | ||
(0, _lodashObjectAssign2['default'])(result, { | ||
bind: _bind2['default'], | ||
bind: _bindBind2['default'], | ||
tap: _tap2['default'], | ||
bindAll: _bindAll2['default'] | ||
bindAll: _bindBindAll2['default'] | ||
}); | ||
@@ -78,0 +78,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A collection of decorators using lodash at it's core.", | ||
"version": "0.4.12", | ||
"version": "0.4.13", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">=0.12.0" |
@@ -16,2 +16,6 @@ 'use strict'; | ||
var _log = require('./log'); | ||
var _log2 = _interopRequireDefault(_log); | ||
function createValidateDecorator(validateFactory) { | ||
@@ -42,3 +46,3 @@ return (0, _decoratorFactory.createDecorator)(function validateDecorator(fn) { | ||
if (validators[i] && !validators[i](args[i])) { | ||
throw new TypeError('Argument did not pass validation. Got ' + typeof arg + '.'); | ||
throw new TypeError((0, _log2['default'])('Argument did not pass validation. Got ' + typeof arg + '.')); | ||
} | ||
@@ -45,0 +49,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49045
28
883