lodash-decorators
Advanced tools
Comparing version 0.4.11 to 0.4.12
@@ -53,3 +53,3 @@ 'use strict'; | ||
return fn.apply(undefined, [Applicator.resolveFunction(args[0], target)].concat(_toConsumableArray(args.slice(1)))).apply(this, invokeArgs); | ||
return fn.apply(undefined, [Applicator.resolveFunction(args[0], this)].concat(_toConsumableArray(args.slice(1)))).apply(this, invokeArgs); | ||
}; | ||
@@ -66,3 +66,3 @@ }, | ||
return fn(Applicator.resolveFunction(fnName, target), value).apply(this, invokeArgs); | ||
return fn(Applicator.resolveFunction(fnName, this), value).apply(this, invokeArgs); | ||
}; | ||
@@ -86,2 +86,4 @@ }, | ||
return function () { | ||
var _this = this; | ||
for (var _len8 = arguments.length, invokeArgs = Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { | ||
@@ -92,3 +94,3 @@ invokeArgs[_key8] = arguments[_key8]; | ||
return fn.apply(undefined, [value].concat(_toConsumableArray(args.map(function (method) { | ||
return Applicator.resolveFunction(method, target); | ||
return Applicator.resolveFunction(method, _this); | ||
})))).apply(this, invokeArgs); | ||
@@ -95,0 +97,0 @@ }; |
@@ -28,3 +28,3 @@ 'use strict'; | ||
warn('Method ' + fn.name + ' is deprecated. This feature will be removed in the future.'); | ||
deprecated.methodAction(fn); | ||
@@ -35,2 +35,5 @@ return fn.apply(this, args); | ||
defineFunctionProp(deprecated, 'classAction', defaultClassAction); | ||
defineFunctionProp(deprecated, 'methodAction', defaultMethodAction); | ||
/** | ||
@@ -48,3 +51,3 @@ * Warns when a deprecated function is being used. | ||
warn('Class ' + target.name + ' is deprecated. This feature will be removed in the future.'); | ||
deprecated.classAction(target); | ||
@@ -58,2 +61,24 @@ return Ctor.apply(this, args); | ||
function defineFunctionProp(target, name, defaultAction) { | ||
Object.defineProperty(target, name, { | ||
configurable: false, | ||
get: function get() { | ||
return defaultAction; | ||
}, | ||
set: function set(val) { | ||
if ((0, _lodashLangIsFunction2['default'])(val)) { | ||
defaultAction = val; | ||
} | ||
} | ||
}); | ||
} | ||
function defaultClassAction(target) { | ||
warn('Class ' + target.name + ' is deprecated. This feature will be removed in the future.'); | ||
} | ||
function defaultMethodAction(fn) { | ||
warn('Method ' + fn.name + ' is deprecated. This feature will be removed in the future.'); | ||
} | ||
function warn() { | ||
@@ -60,0 +85,0 @@ var message = arguments[0] === undefined ? '' : arguments[0]; |
@@ -5,3 +5,3 @@ { | ||
"description": "A collection of decorators using lodash at it's core.", | ||
"version": "0.4.11", | ||
"version": "0.4.12", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">=0.12.0" |
@@ -338,2 +338,3 @@ # lodash-decorators | ||
Warns when a deprecated class is istantiated or a deprecated class method is invoked. | ||
You can also modify the deprecated behaviour by swapping out the method and class actions. | ||
@@ -345,2 +346,5 @@ #### Example | ||
// This is applied globally. | ||
deprecated.methodAction = fn => console.log(`Don't use ${fn.name}!`); | ||
@deprecated | ||
@@ -359,3 +363,3 @@ class Person { | ||
let otherPerson = new OtherPerson(); | ||
otherPerson.fn(); //=> Warning! | ||
otherPerson.fn(); //=> Don't use fn! | ||
``` | ||
@@ -362,0 +366,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
47185
843
372