lodash-decorators
Advanced tools
Comparing version 4.5.0 to 5.0.0
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedMethodDecorator } from './factory'; | ||
/** | ||
@@ -24,4 +23,4 @@ * Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked. | ||
*/ | ||
export declare function Attempt(...partials: any[]): LodashMethodDecorator; | ||
export declare const Attempt: BiTypedMethodDecorator; | ||
export { Attempt as attempt }; | ||
export default decorator; | ||
export default Attempt; |
@@ -8,3 +8,2 @@ "use strict"; | ||
var attemptFn = function (fn) { return partial(attempt, fn); }; | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(attemptFn, new applicators_1.PreValueApplicator())); | ||
/** | ||
@@ -31,12 +30,7 @@ * Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked. | ||
*/ | ||
function Attempt() { | ||
var partials = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
partials[_i] = arguments[_i]; | ||
} | ||
return decorator.apply(void 0, partials); | ||
} | ||
exports.Attempt = Attempt; | ||
exports.attempt = Attempt; | ||
exports.default = decorator; | ||
exports.Attempt = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(attemptFn, new applicators_1.PreValueApplicator(), { | ||
optionalParams: true | ||
})); | ||
exports.attempt = exports.Attempt; | ||
exports.default = exports.Attempt; | ||
//# sourceMappingURL=attempt.js.map |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
/** | ||
@@ -28,4 +27,4 @@ * Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives. | ||
*/ | ||
export declare function Bind(...partials: any[]): LodashMethodDecorator; | ||
export declare const Bind: BiTypedMethodDecorator1<any>; | ||
export { Bind as bind }; | ||
export default decorator; | ||
export default Bind; |
16
bind.js
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(bind, new applicators_1.BindApplicator())); | ||
/** | ||
@@ -33,12 +32,7 @@ * Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives. | ||
*/ | ||
function Bind() { | ||
var partials = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
partials[_i] = arguments[_i]; | ||
} | ||
return decorator.apply(void 0, partials); | ||
} | ||
exports.Bind = Bind; | ||
exports.bind = Bind; | ||
exports.default = decorator; | ||
exports.Bind = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(bind, new applicators_1.BindApplicator(), { | ||
optionalParams: true | ||
})); | ||
exports.bind = exports.Bind; | ||
exports.default = exports.Bind; | ||
//# sourceMappingURL=bind.js.map |
@@ -5,2 +5,20 @@ # Change Log | ||
<a name="5.0.0"></a> | ||
# [5.0.0](https://github.com/steelsojka/lodash-decorators/compare/v4.5.0...v5.0.0) (2018-03-17) | ||
### Features | ||
* **all:** decorators with optional arguments do not require invocation ([59a71d7](https://github.com/steelsojka/lodash-decorators/commit/59a71d7)) | ||
* **all:** initial work for paramless decorators ([5300a2e](https://github.com/steelsojka/lodash-decorators/commit/5300a2e)) | ||
### BREAKING CHANGES | ||
* **all:** This may cause issue with tools that rely on static analysis of the | ||
decorators. Since the deocorators are typed with intersections they must | ||
be removed from a static function wrapper. | ||
<a name="4.5.0"></a> | ||
@@ -7,0 +25,0 @@ # [4.5.0](https://github.com/steelsojka/lodash-decorators/compare/v4.4.0...v4.5.0) (2017-11-03) |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
/** | ||
@@ -29,4 +28,4 @@ * Creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments, and so on. | ||
*/ | ||
export declare function Curry(arity?: number): LodashMethodDecorator; | ||
export declare const Curry: BiTypedMethodDecorator1<number>; | ||
export { Curry as curry }; | ||
export default decorator; | ||
export default Curry; |
10
curry.js
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(curry, new applicators_1.PreValueApplicator(), { bound: true })); | ||
/** | ||
@@ -34,8 +33,5 @@ * Creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments, and so on. | ||
*/ | ||
function Curry(arity) { | ||
return decorator(arity); | ||
} | ||
exports.Curry = Curry; | ||
exports.curry = Curry; | ||
exports.default = decorator; | ||
exports.Curry = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(curry, new applicators_1.PreValueApplicator(), { bound: true, optionalParams: true })); | ||
exports.curry = exports.Curry; | ||
exports.default = exports.Curry; | ||
//# sourceMappingURL=curry.js.map |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedDecorator1 } from './factory'; | ||
/** | ||
@@ -27,4 +26,4 @@ * Creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments, and so on. | ||
*/ | ||
export declare function CurryAll(arity?: number): LodashMethodDecorator; | ||
export declare const CurryAll: BiTypedDecorator1<number>; | ||
export { CurryAll as curryAll }; | ||
export default decorator; | ||
export default CurryAll; |
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(curry, new applicators_1.PreValueApplicator())); | ||
/** | ||
@@ -32,8 +31,5 @@ * Creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments, and so on. | ||
*/ | ||
function CurryAll(arity) { | ||
return decorator(arity); | ||
} | ||
exports.CurryAll = CurryAll; | ||
exports.curryAll = CurryAll; | ||
exports.default = decorator; | ||
exports.CurryAll = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(curry, new applicators_1.PreValueApplicator(), { optionalParams: true })); | ||
exports.curryAll = exports.CurryAll; | ||
exports.default = exports.CurryAll; | ||
//# sourceMappingURL=curryAll.js.map |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
/** | ||
@@ -29,4 +28,4 @@ * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. | ||
*/ | ||
export declare function CurryRight(arity?: number): LodashMethodDecorator; | ||
export declare const CurryRight: BiTypedMethodDecorator1<number>; | ||
export { CurryRight as curryRight }; | ||
export default decorator; | ||
export default CurryRight; |
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(curryRight, new applicators_1.PreValueApplicator(), { bound: true })); | ||
/** | ||
@@ -34,8 +33,5 @@ * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. | ||
*/ | ||
function CurryRight(arity) { | ||
return decorator(arity); | ||
} | ||
exports.CurryRight = CurryRight; | ||
exports.curryRight = CurryRight; | ||
exports.default = decorator; | ||
exports.CurryRight = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(curryRight, new applicators_1.PreValueApplicator(), { bound: true, optionalParams: true })); | ||
exports.curryRight = exports.CurryRight; | ||
exports.default = exports.CurryRight; | ||
//# sourceMappingURL=curryRight.js.map |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
/** | ||
@@ -27,4 +26,4 @@ * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. | ||
*/ | ||
export declare function CurryRightAll(arity?: number): LodashMethodDecorator; | ||
export declare const CurryRightAll: BiTypedMethodDecorator1<number>; | ||
export { CurryRightAll as curryRightAll }; | ||
export default decorator; | ||
export default CurryRightAll; |
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(curryRight, new applicators_1.PreValueApplicator())); | ||
/** | ||
@@ -32,8 +31,5 @@ * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. | ||
*/ | ||
function CurryRightAll(arity) { | ||
return decorator(arity); | ||
} | ||
exports.CurryRightAll = CurryRightAll; | ||
exports.curryRightAll = CurryRightAll; | ||
exports.default = decorator; | ||
exports.CurryRightAll = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(curryRight, new applicators_1.PreValueApplicator(), { optionalParams: true })); | ||
exports.curryRightAll = exports.CurryRightAll; | ||
exports.default = exports.CurryRightAll; | ||
//# sourceMappingURL=curryRightAll.js.map |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedDecoratorN } from './factory'; | ||
/** | ||
@@ -28,4 +27,4 @@ * Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked. | ||
*/ | ||
export declare function Defer(...args: any[]): LodashMethodDecorator; | ||
export declare const Defer: BiTypedDecoratorN; | ||
export { Defer as defer }; | ||
export default decorator; | ||
export default Defer; |
14
defer.js
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(defer, new applicators_1.InvokeApplicator(), { setter: true })); | ||
/** | ||
@@ -33,12 +32,5 @@ * Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked. | ||
*/ | ||
function Defer() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return decorator.apply(void 0, args); | ||
} | ||
exports.Defer = Defer; | ||
exports.defer = Defer; | ||
exports.default = decorator; | ||
exports.Defer = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(defer, new applicators_1.InvokeApplicator(), { setter: true, optionalParams: true })); | ||
exports.defer = exports.Defer; | ||
exports.default = exports.Defer; | ||
//# sourceMappingURL=defer.js.map |
@@ -9,2 +9,12 @@ import { Applicator } from '../applicators'; | ||
export declare type ResolvableFunction = string | Function; | ||
export declare type BiTypedMethodDecorator = (() => LodashMethodDecorator) & LodashMethodDecorator; | ||
export declare type BiTypedMethodDecorator1<T> = ((arg?: T) => LodashMethodDecorator) & LodashMethodDecorator; | ||
export declare type BiTypedMethodDecorator2<T, T2> = ((arg1?: T, arg2?: T2) => LodashMethodDecorator) & LodashMethodDecorator; | ||
export declare type BiTypedMethodDecorator3<T, T2, T3> = ((arg1?: T, arg2?: T2, arg3?: T3) => LodashMethodDecorator) & LodashMethodDecorator; | ||
export declare type BiTypedMethodDecoratorN = ((...args: any[]) => LodashMethodDecorator) & LodashMethodDecorator; | ||
export declare type BiTypedDecorator = (() => LodashDecorator) & LodashDecorator; | ||
export declare type BiTypedDecorator1<T> = ((arg?: T) => LodashDecorator) & LodashDecorator; | ||
export declare type BiTypedDecorator2<T, T2> = ((arg1?: T, arg2?: T2) => LodashDecorator) & LodashDecorator; | ||
export declare type BiTypedDecorator3<T, T2, T3> = ((arg1?: T, arg2?: T2, arg3?: T3) => LodashDecorator) & LodashDecorator; | ||
export declare type BiTypedDecoratorN = ((...args: any[]) => LodashDecorator) & LodashDecorator; | ||
export interface InstanceChainContext { | ||
@@ -11,0 +21,0 @@ getter?: boolean; |
@@ -8,2 +8,3 @@ import { Applicator } from '../applicators'; | ||
method?: boolean; | ||
optionalParams?: boolean; | ||
} | ||
@@ -20,2 +21,3 @@ export declare class DecoratorConfig { | ||
readonly method: boolean; | ||
readonly optionalParams: boolean; | ||
} |
@@ -45,2 +45,9 @@ "use strict"; | ||
}); | ||
Object.defineProperty(DecoratorConfig.prototype, "optionalParams", { | ||
get: function () { | ||
return this.options.optionalParams != null ? this.options.optionalParams : false; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return DecoratorConfig; | ||
@@ -47,0 +54,0 @@ }()); |
@@ -11,3 +11,3 @@ "use strict"; | ||
var _this = this; | ||
var applicator = config.applicator; | ||
var applicator = config.applicator, optionalParams = config.optionalParams; | ||
return function () { | ||
@@ -18,3 +18,4 @@ var args = []; | ||
} | ||
return function (target, name, _descriptor) { | ||
var params = args; | ||
var decorator = function (target, name, _descriptor) { | ||
var descriptor = _this._resolveDescriptor(target, name, _descriptor); | ||
@@ -26,9 +27,9 @@ var value = descriptor.value, get = descriptor.get, set = descriptor.set; | ||
if (isFunction(value)) { | ||
descriptor.value = utils_1.copyMetadata(applicator.apply({ config: config, target: target, value: value, args: args }), value); | ||
descriptor.value = utils_1.copyMetadata(applicator.apply({ config: config, target: target, value: value, args: params }), value); | ||
} | ||
else if (isFunction(get) && config.getter) { | ||
descriptor.get = utils_1.copyMetadata(applicator.apply({ config: config, target: target, value: get, args: args }), get); | ||
descriptor.get = utils_1.copyMetadata(applicator.apply({ config: config, target: target, value: get, args: params }), get); | ||
} | ||
else if (isFunction(set) && config.setter) { | ||
descriptor.set = utils_1.copyMetadata(applicator.apply({ config: config, target: target, value: set, args: args }), get); | ||
descriptor.set = utils_1.copyMetadata(applicator.apply({ config: config, target: target, value: set, args: params }), set); | ||
} | ||
@@ -38,2 +39,7 @@ } | ||
}; | ||
if (optionalParams && utils_1.isMethodOrPropertyDecoratorArgs.apply(void 0, args)) { | ||
params = []; | ||
return decorator(args[0], args[1], args[2]); | ||
} | ||
return decorator; | ||
}; | ||
@@ -43,3 +49,3 @@ }; | ||
var _this = this; | ||
var applicator = config.applicator, bound = config.bound; | ||
var applicator = config.applicator, bound = config.bound, optionalParams = config.optionalParams; | ||
return function () { | ||
@@ -50,3 +56,4 @@ var args = []; | ||
} | ||
return function (target, name, _descriptor) { | ||
var params = args; | ||
var decorator = function (target, name, _descriptor) { | ||
var descriptor = _this._resolveDescriptor(target, name, _descriptor); | ||
@@ -68,3 +75,3 @@ var value = descriptor.value, writable = descriptor.writable, enumerable = descriptor.enumerable, configurable = descriptor.configurable, get = descriptor.get, set = descriptor.set; | ||
} | ||
return utils_1.copyMetadata(applicator.apply({ args: args, target: target, instance: instance, value: fn, config: config }), fn); | ||
return utils_1.copyMetadata(applicator.apply({ args: params, target: target, instance: instance, value: fn, config: config }), fn); | ||
}); | ||
@@ -136,2 +143,7 @@ common_1.InstanceChainMap.set([target, name], chainData); | ||
}; | ||
if (optionalParams && utils_1.isMethodOrPropertyDecoratorArgs.apply(void 0, args)) { | ||
params = []; | ||
return decorator(args[0], args[1], args[2]); | ||
} | ||
return decorator; | ||
}; | ||
@@ -138,0 +150,0 @@ }; |
@@ -1,4 +0,3 @@ | ||
import { LodashMethodDecorator, ResolvableFunction } from './factory'; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
import { MemoizeConfig } from './shared'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
/** | ||
@@ -28,4 +27,4 @@ * Creates a function that memoizes the result of func. If resolver is provided, | ||
*/ | ||
export declare function Memoize(resolver?: ResolvableFunction | MemoizeConfig<any, any>): LodashMethodDecorator; | ||
export declare const Memoize: BiTypedMethodDecorator1<string | Function | MemoizeConfig<any, any>>; | ||
export { Memoize as memoize }; | ||
export default decorator; | ||
export default Memoize; |
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(memoize, new applicators_1.MemoizeApplicator())); | ||
/** | ||
@@ -32,8 +31,5 @@ * Creates a function that memoizes the result of func. If resolver is provided, | ||
*/ | ||
function Memoize(resolver) { | ||
return decorator(resolver); | ||
} | ||
exports.Memoize = Memoize; | ||
exports.memoize = Memoize; | ||
exports.default = decorator; | ||
exports.Memoize = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(memoize, new applicators_1.MemoizeApplicator(), { optionalParams: true })); | ||
exports.memoize = exports.Memoize; | ||
exports.default = exports.Memoize; | ||
//# sourceMappingURL=memoize.js.map |
@@ -1,4 +0,3 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
import { MemoizeConfig } from './shared'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
/** | ||
@@ -8,4 +7,4 @@ * Memoizes a function on the prototype instead of the instance. All instances of the class use the same memoize cache. | ||
*/ | ||
export declare function MemoizeAll(resolver?: Function | MemoizeConfig<any, any>): LodashMethodDecorator; | ||
export declare const MemoizeAll: BiTypedMethodDecorator1<Function | MemoizeConfig<any, any>>; | ||
export { MemoizeAll as memoizeAll }; | ||
export default decorator; | ||
export default MemoizeAll; |
@@ -6,3 +6,2 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(memoize, new applicators_1.MemoizeApplicator())); | ||
/** | ||
@@ -12,8 +11,5 @@ * Memoizes a function on the prototype instead of the instance. All instances of the class use the same memoize cache. | ||
*/ | ||
function MemoizeAll(resolver) { | ||
return decorator(resolver); | ||
} | ||
exports.MemoizeAll = MemoizeAll; | ||
exports.memoizeAll = MemoizeAll; | ||
exports.default = decorator; | ||
exports.MemoizeAll = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(memoize, new applicators_1.MemoizeApplicator(), { optionalParams: true })); | ||
exports.memoizeAll = exports.MemoizeAll; | ||
exports.default = exports.MemoizeAll; | ||
//# sourceMappingURL=memoizeAll.js.map |
@@ -27,6 +27,6 @@ "use strict"; | ||
} | ||
return function (target) { | ||
return (function (target) { | ||
assign.apply(void 0, [target.prototype].concat(srcs)); | ||
return target; | ||
}; | ||
}); | ||
} | ||
@@ -33,0 +33,0 @@ exports.Mixin = Mixin; |
@@ -1,5 +0,22 @@ | ||
import { LodashDecorator, ResolvableFunction } from './factory'; | ||
declare const decorator: (...args: any[]) => LodashDecorator; | ||
export declare function Negate(fn?: ResolvableFunction): LodashDecorator; | ||
import { BiTypedDecorator1 } from './factory'; | ||
/** | ||
* Negates a functions result or, when used on a property, creates a function that | ||
* negates the result of a provided function. | ||
* @param {ResolvableFunction} [fn] A resolvable function. | ||
* @example | ||
* class MyClass { | ||
* @Negate('fn') | ||
* fn2: () => boolean; | ||
* | ||
* fn(): boolean { | ||
* return true; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn2(); //=> false | ||
*/ | ||
export declare const Negate: BiTypedDecorator1<string | Function>; | ||
export { Negate as negate }; | ||
export default decorator; | ||
export default Negate; |
@@ -6,9 +6,23 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(negate, new applicators_1.PartialValueApplicator(), { property: true })); | ||
function Negate(fn) { | ||
return decorator(fn); | ||
} | ||
exports.Negate = Negate; | ||
exports.negate = Negate; | ||
exports.default = decorator; | ||
/** | ||
* Negates a functions result or, when used on a property, creates a function that | ||
* negates the result of a provided function. | ||
* @param {ResolvableFunction} [fn] A resolvable function. | ||
* @example | ||
* class MyClass { | ||
* @Negate('fn') | ||
* fn2: () => boolean; | ||
* | ||
* fn(): boolean { | ||
* return true; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn2(); //=> false | ||
*/ | ||
exports.Negate = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(negate, new applicators_1.PartialValueApplicator(), { property: true, optionalParams: true })); | ||
exports.negate = exports.Negate; | ||
exports.default = exports.Negate; | ||
//# sourceMappingURL=negate.js.map |
@@ -1,5 +0,22 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
export declare function Once(): LodashMethodDecorator; | ||
import { BiTypedDecorator } from './factory'; | ||
/** | ||
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. | ||
* @example | ||
* class MyClass { | ||
* value: number = 0; | ||
* | ||
* @Once() | ||
* fn(): number { | ||
* return ++this.value; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn(); //=> 1 | ||
* myClass.fn(); //=> 1 | ||
* myClass.fn(); //=> 1 | ||
*/ | ||
export declare const Once: BiTypedDecorator; | ||
export { Once as once }; | ||
export default decorator; | ||
export default Once; |
28
once.js
@@ -6,9 +6,23 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(once, new applicators_1.PreValueApplicator(), { setter: true })); | ||
function Once() { | ||
return decorator(); | ||
} | ||
exports.Once = Once; | ||
exports.once = Once; | ||
exports.default = decorator; | ||
/** | ||
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. | ||
* @example | ||
* class MyClass { | ||
* value: number = 0; | ||
* | ||
* @Once() | ||
* fn(): number { | ||
* return ++this.value; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn(); //=> 1 | ||
* myClass.fn(); //=> 1 | ||
* myClass.fn(); //=> 1 | ||
*/ | ||
exports.Once = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(once, new applicators_1.PreValueApplicator(), { setter: true, optionalParams: true })); | ||
exports.once = exports.Once; | ||
exports.default = exports.Once; | ||
//# sourceMappingURL=once.js.map |
@@ -1,5 +0,23 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
export declare function OnceAll(): LodashMethodDecorator; | ||
import { BiTypedDecorator } from './factory'; | ||
/** | ||
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. | ||
* This is shared across all instances of the class. | ||
* @example | ||
* const value = 0; | ||
* | ||
* class MyClass { | ||
* @Once() | ||
* fn(): number { | ||
* return ++value; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* const myClass2 = new MyClass(); | ||
* | ||
* myClass.fn(); //=> 1 | ||
* myClass2.fn(); //=> 1 | ||
*/ | ||
export declare const OnceAll: BiTypedDecorator; | ||
export { OnceAll as onceAll }; | ||
export default decorator; | ||
export default OnceAll; |
@@ -6,9 +6,24 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(once, new applicators_1.PreValueApplicator(), { setter: true })); | ||
function OnceAll() { | ||
return decorator(); | ||
} | ||
exports.OnceAll = OnceAll; | ||
exports.onceAll = OnceAll; | ||
exports.default = decorator; | ||
/** | ||
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. | ||
* This is shared across all instances of the class. | ||
* @example | ||
* const value = 0; | ||
* | ||
* class MyClass { | ||
* @Once() | ||
* fn(): number { | ||
* return ++value; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* const myClass2 = new MyClass(); | ||
* | ||
* myClass.fn(); //=> 1 | ||
* myClass2.fn(); //=> 1 | ||
*/ | ||
exports.OnceAll = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(once, new applicators_1.PreValueApplicator(), { setter: true, optionalParams: true })); | ||
exports.onceAll = exports.OnceAll; | ||
exports.default = exports.OnceAll; | ||
//# sourceMappingURL=onceAll.js.map |
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
/** | ||
* Creates a function that invokes func with its arguments transformed. | ||
* @export | ||
* @param {...Function[]} transforms | ||
* @returns {LodashMethodDecorator} | ||
* @example | ||
* class MyClass { | ||
* @OverArgs(_.castArray) | ||
* fn(list) { | ||
* return list; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn([ 1 ]); //=> [ 1 ]; | ||
* myClass.fn(1); //=> [ 1 ]; | ||
*/ | ||
export declare function OverArgs(...transforms: Function[]): LodashMethodDecorator; | ||
export { OverArgs as overArgs }; | ||
export default decorator; |
@@ -7,2 +7,20 @@ "use strict"; | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(overArgs, new applicators_1.PreValueApplicator(), { setter: true })); | ||
/** | ||
* Creates a function that invokes func with its arguments transformed. | ||
* @export | ||
* @param {...Function[]} transforms | ||
* @returns {LodashMethodDecorator} | ||
* @example | ||
* class MyClass { | ||
* @OverArgs(_.castArray) | ||
* fn(list) { | ||
* return list; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn([ 1 ]); //=> [ 1 ]; | ||
* myClass.fn(1); //=> [ 1 ]; | ||
*/ | ||
function OverArgs() { | ||
@@ -9,0 +27,0 @@ var transforms = []; |
@@ -5,3 +5,3 @@ { | ||
"description": "A collection of decorators using lodash at it's core.", | ||
"version": "4.5.0", | ||
"version": "5.0.0", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">=0.12.0" |
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
/** | ||
* Partially applies arguments to a function. | ||
* @export | ||
* @param {...any[]} partials | ||
* @returns {PropertyDecorator} | ||
* @example | ||
* class MyClass { | ||
* lastName: string = 'Schmo'; | ||
* | ||
* @Partial('fn', 'Joe') | ||
* fn2: () => string; | ||
* | ||
* fn(name: string): string { | ||
* return `${name} ${this.lastName}`; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn2(); //=> 'Joe Schmo' | ||
*/ | ||
export declare function Partial(...partials: any[]): PropertyDecorator; | ||
export { Partial as partial }; | ||
export default decorator; |
@@ -7,2 +7,23 @@ "use strict"; | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(partial, new applicators_1.PartialApplicator(), { property: true, method: false })); | ||
/** | ||
* Partially applies arguments to a function. | ||
* @export | ||
* @param {...any[]} partials | ||
* @returns {PropertyDecorator} | ||
* @example | ||
* class MyClass { | ||
* lastName: string = 'Schmo'; | ||
* | ||
* @Partial('fn', 'Joe') | ||
* fn2: () => string; | ||
* | ||
* fn(name: string): string { | ||
* return `${name} ${this.lastName}`; | ||
* } | ||
* } | ||
* | ||
* const myClass = new MyClass(); | ||
* | ||
* myClass.fn2(); //=> 'Joe Schmo' | ||
*/ | ||
function Partial() { | ||
@@ -9,0 +30,0 @@ var partials = []; |
@@ -375,3 +375,3 @@ # lodash-decorators | ||
All decorators now take arguments. So instead of `@Once` you would do `@Once()`. This keeps the API consistent and doesn't require the develop to remember which decorators take arguments. | ||
All decorators now take arguments. So instead of `@Once` you would do `@Once()`. This keeps the API consistent and doesn't require the developer to remember which decorators take arguments. | ||
@@ -378,0 +378,0 @@ #### Removal of extensions and validation package |
@@ -1,5 +0,4 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
export declare function Rest(start?: number): LodashMethodDecorator; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
export declare const Rest: BiTypedMethodDecorator1<number>; | ||
export { Rest as rest }; | ||
export default decorator; | ||
export default Rest; |
10
rest.js
@@ -6,9 +6,5 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(rest, new applicators_1.PreValueApplicator())); | ||
function Rest(start) { | ||
return decorator(start); | ||
} | ||
exports.Rest = Rest; | ||
exports.rest = Rest; | ||
exports.default = decorator; | ||
exports.Rest = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(rest, new applicators_1.PreValueApplicator(), { optionalParams: true })); | ||
exports.rest = exports.Rest; | ||
exports.default = exports.Rest; | ||
//# sourceMappingURL=rest.js.map |
@@ -1,5 +0,4 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
export declare function Spread(start?: number): LodashMethodDecorator; | ||
import { BiTypedMethodDecorator1 } from './factory'; | ||
export declare const Spread: BiTypedMethodDecorator1<number>; | ||
export { Spread as spread }; | ||
export default decorator; | ||
export default Spread; |
@@ -6,9 +6,5 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(spread, new applicators_1.PreValueApplicator())); | ||
function Spread(start) { | ||
return decorator(start); | ||
} | ||
exports.Spread = Spread; | ||
exports.spread = Spread; | ||
exports.default = decorator; | ||
exports.Spread = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(spread, new applicators_1.PreValueApplicator(), { optionalParams: true })); | ||
exports.spread = exports.Spread; | ||
exports.default = exports.Spread; | ||
//# sourceMappingURL=spread.js.map |
@@ -1,3 +0,2 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
import { BiTypedMethodDecorator } from './factory'; | ||
/** | ||
@@ -7,4 +6,4 @@ * Returns the first argument from the function regardless of | ||
*/ | ||
export declare function Tap(): LodashMethodDecorator; | ||
export declare const Tap: BiTypedMethodDecorator; | ||
export { Tap as tap }; | ||
export default decorator; | ||
export default Tap; |
10
tap.js
@@ -6,3 +6,2 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(function (fn) { return utils_1.returnAtIndex(fn, 0); }, new applicators_1.PreValueApplicator())); | ||
/** | ||
@@ -12,8 +11,5 @@ * Returns the first argument from the function regardless of | ||
*/ | ||
function Tap() { | ||
return decorator(); | ||
} | ||
exports.Tap = Tap; | ||
exports.tap = Tap; | ||
exports.default = decorator; | ||
exports.Tap = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(function (fn) { return utils_1.returnAtIndex(fn, 0); }, new applicators_1.PreValueApplicator(), { optionalParams: true })); | ||
exports.tap = exports.Tap; | ||
exports.default = exports.Tap; | ||
//# sourceMappingURL=tap.js.map |
@@ -1,10 +0,9 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
import { BiTypedDecorator2 } from './factory'; | ||
import { ThrottleOptions } from './shared'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
export declare function Throttle(wait?: number, options?: ThrottleOptions): LodashMethodDecorator; | ||
export declare function ThrottleGetter(wait?: number, options?: ThrottleOptions): LodashMethodDecorator; | ||
export declare function ThrottleSetter(wait?: number, options?: ThrottleOptions): LodashMethodDecorator; | ||
export declare const Throttle: BiTypedDecorator2<number, ThrottleOptions>; | ||
export declare const ThrottleGetter: BiTypedDecorator2<number, ThrottleOptions>; | ||
export declare const ThrottleSetter: BiTypedDecorator2<number, ThrottleOptions>; | ||
export { Throttle as throttle }; | ||
export { ThrottleGetter as throttleGetter }; | ||
export { ThrottleSetter as throttleSetter }; | ||
export default decorator; | ||
export default Throttle; |
@@ -6,21 +6,9 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(throttle, new applicators_1.PreValueApplicator(), { setter: true, getter: true })); | ||
var decoratorGetter = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(throttle, new applicators_1.PreValueApplicator(), { getter: true })); | ||
var decoratorSetter = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(throttle, new applicators_1.PreValueApplicator(), { setter: true })); | ||
function Throttle(wait, options) { | ||
return decorator(wait, options); | ||
} | ||
exports.Throttle = Throttle; | ||
exports.throttle = Throttle; | ||
function ThrottleGetter(wait, options) { | ||
return decoratorGetter(wait, options); | ||
} | ||
exports.ThrottleGetter = ThrottleGetter; | ||
exports.throttleGetter = ThrottleGetter; | ||
function ThrottleSetter(wait, options) { | ||
return decoratorSetter(wait, options); | ||
} | ||
exports.ThrottleSetter = ThrottleSetter; | ||
exports.throttleSetter = ThrottleSetter; | ||
exports.default = decorator; | ||
exports.Throttle = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(throttle, new applicators_1.PreValueApplicator(), { setter: true, getter: true, optionalParams: true })); | ||
exports.throttle = exports.Throttle; | ||
exports.ThrottleGetter = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(throttle, new applicators_1.PreValueApplicator(), { getter: true, optionalParams: true })); | ||
exports.throttleGetter = exports.ThrottleGetter; | ||
exports.ThrottleSetter = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(throttle, new applicators_1.PreValueApplicator(), { setter: true, optionalParams: true })); | ||
exports.throttleSetter = exports.ThrottleSetter; | ||
exports.default = exports.Throttle; | ||
//# sourceMappingURL=throttle.js.map |
@@ -1,5 +0,4 @@ | ||
import { LodashMethodDecorator } from './factory'; | ||
declare const decorator: (...args: any[]) => MethodDecorator & PropertyDecorator; | ||
export declare function Unary(): LodashMethodDecorator; | ||
import { BiTypedMethodDecorator } from './factory'; | ||
export declare const Unary: BiTypedMethodDecorator; | ||
export { Unary as unary }; | ||
export default decorator; | ||
export default Unary; |
10
unary.js
@@ -6,9 +6,5 @@ "use strict"; | ||
var applicators_1 = require("./applicators"); | ||
var decorator = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(unary, new applicators_1.PreValueApplicator())); | ||
function Unary() { | ||
return decorator(); | ||
} | ||
exports.Unary = Unary; | ||
exports.unary = Unary; | ||
exports.default = decorator; | ||
exports.Unary = factory_1.DecoratorFactory.createDecorator(new factory_1.DecoratorConfig(unary, new applicators_1.PreValueApplicator(), { optionalParams: true })); | ||
exports.unary = exports.Unary; | ||
exports.default = exports.Unary; | ||
//# sourceMappingURL=unary.js.map |
@@ -9,1 +9,2 @@ export * from './utils/log'; | ||
export * from './utils/assignAll'; | ||
export * from './utils/isDecoratorArgs'; |
@@ -14,2 +14,3 @@ "use strict"; | ||
__export(require("./utils/assignAll")); | ||
__export(require("./utils/isDecoratorArgs")); | ||
//# sourceMappingURL=utils.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
220507
199
2930