lodash-decorators
- Version 6.0.1
- Published
- 269 kB
- 1 dependency
- MIT license
Install
npm i lodash-decorators
yarn add lodash-decorators
pnpm add lodash-decorators
Overview
A collection of decorators using lodash at it's core.
Index
Variables
Functions
- after()
- After()
- afterAll()
- AfterAll()
- ary()
- Ary()
- before()
- Before()
- beforeAll()
- BeforeAll()
- bindAll()
- BindAll()
- debounce()
- Debounce()
- debounceAll()
- DebounceAll()
- delay()
- Delay()
- flip()
- Flip()
- flow()
- Flow()
- flowRight()
- FlowRight()
- mixin()
- Mixin()
- overArgs()
- OverArgs()
- partial()
- Partial()
- partialRight()
- PartialRight()
- rearg()
- Rearg()
- throttleAll()
- ThrottleAll()
- wrap()
- Wrap()
Classes
Interfaces
Type Aliases
Variables
variable attempt
const attempt: BiTypedMethodDecorator;
Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked.
Parameter args
The arguments to invoke func with.
Example 1
class MyClass { @Attempt() fn(value) { if (typeof value === 'number') { return value }
throw new Error(); } }
const myClass = new MyClass();
myClass.fn(10); // => 10; myClass.fn(null); // => Error
variable Attempt
const Attempt: BiTypedMethodDecorator;
Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked.
Parameter args
The arguments to invoke func with.
Example 1
class MyClass { @Attempt() fn(value) { if (typeof value === 'number') { return value }
throw new Error(); } }
const myClass = new MyClass();
myClass.fn(10); // => 10; myClass.fn(null); // => Error
variable bind
const bind: BiTypedMethodDecorator1<any>;
Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.
The _.bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.
Note: Unlike native Function#bind, this method doesn't set the "length" property of bound functions.
Parameter partials
The argument to be partially applied.
Example 1
class MyClass { @Bind() bound() { return this; }
unbound() { return this; } }
const myClass = new MyClass();
myClass.bound.call(null); // => myClass {} myClass.unbound.call(null); // => null
variable Bind
const Bind: BiTypedMethodDecorator1<any>;
Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives.
The _.bind.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.
Note: Unlike native Function#bind, this method doesn't set the "length" property of bound functions.
Parameter partials
The argument to be partially applied.
Example 1
class MyClass { @Bind() bound() { return this; }
unbound() { return this; } }
const myClass = new MyClass();
myClass.bound.call(null); // => myClass {} myClass.unbound.call(null); // => null
variable curry
const curry: BiTypedMethodDecorator1<number>;
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. The arity of func may be specified if func.length is not sufficient. The original function is bound to the instance. If the method is needed to call in a different context use
CurryAll
.The _.curry.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions.
Parameter arity
The arity of func.
Example 1
class MyClass { multiplier = 2;
@Curry() add(a, b) { return (a + b) * this.multiplier; } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 30
variable Curry
const Curry: BiTypedMethodDecorator1<number>;
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. The arity of func may be specified if func.length is not sufficient. The original function is bound to the instance. If the method is needed to call in a different context use
CurryAll
.The _.curry.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions.
Parameter arity
The arity of func.
Example 1
class MyClass { multiplier = 2;
@Curry() add(a, b) { return (a + b) * this.multiplier; } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 30
variable curryAll
const curryAll: BiTypedDecorator1<number>;
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. The arity of func may be specified if func.length is not sufficient.
The _.curry.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions. Note: The original function invoked will not be called in the context of the instance. Use
Curry
to for using it bound.Parameter arity
The arity of func.
Example 1
class MyClass { @CurryAll() add(a, b) { return (a + b); } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 15
variable CurryAll
const CurryAll: BiTypedDecorator1<number>;
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. The arity of func may be specified if func.length is not sufficient.
The _.curry.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions. Note: The original function invoked will not be called in the context of the instance. Use
Curry
to for using it bound.Parameter arity
The arity of func.
Example 1
class MyClass { @CurryAll() add(a, b) { return (a + b); } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 15
variable curryRight
const curryRight: BiTypedMethodDecorator1<number>;
This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. The arity of func may be specified if func.length is not sufficient. The original function is bound to the instance. If the method is needed to call in a different context use
CurryAll
.The _.curryRight.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions.
Parameter arity
The arity of func.
Example 1
class MyClass { multiplier = 2;
@CurryRight() add(a, b) { return (a + b) * this.multiplier; } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 30
variable CurryRight
const CurryRight: BiTypedMethodDecorator1<number>;
This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. The arity of func may be specified if func.length is not sufficient. The original function is bound to the instance. If the method is needed to call in a different context use
CurryAll
.The _.curryRight.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions.
Parameter arity
The arity of func.
Example 1
class MyClass { multiplier = 2;
@CurryRight() add(a, b) { return (a + b) * this.multiplier; } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 30
variable curryRightAll
const curryRightAll: BiTypedMethodDecorator1<number>;
This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. The arity of func may be specified if func.length is not sufficient. The original function is bound to the instance. If the method is needed to call in a different context use
CurryAll
.The _.curryRight.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions.
Parameter arity
The arity of func.
Example 1
class MyClass { @CurryRightAll() add(a, b) { return (a + b); } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 15
variable CurryRightAll
const CurryRightAll: BiTypedMethodDecorator1<number>;
This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial. The arity of func may be specified if func.length is not sufficient. The original function is bound to the instance. If the method is needed to call in a different context use
CurryAll
.The _.curryRight.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.
Note: This method doesn't set the "length" property of curried functions.
Parameter arity
The arity of func.
Example 1
class MyClass { @CurryRightAll() add(a, b) { return (a + b); } }
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 15
variable DecoratorFactory
const DecoratorFactory: InternalDecoratorFactory;
variable defer
const defer: BiTypedDecoratorN;
Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.
Parameter args
Additional arguments to invoke the function with
Example 1
class MyClass { value = 100;
@Defer() add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 110; }, 0);
variable Defer
const Defer: BiTypedDecoratorN;
Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.
Parameter args
Additional arguments to invoke the function with
Example 1
class MyClass { value = 100;
@Defer() add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 110; }, 0);
variable InstanceChainMap
const InstanceChainMap: CompositeKeyWeakMap<InstanceChainData>;
variable memoize
const memoize: BiTypedMethodDecorator1<string | Function | MemoizeConfig<any, any>>;
Creates a function that memoizes the result of func. If resolver is provided, it determines the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the map cache key. The func is invoked with the this binding of the memoized function.
You can use a Function or a string that references a method on the class as the resolver. You can also use a configuration object that lets provide a prexisting cache or specify the map type to use.
Example 1
class MyClass { @Memoize({ type: WeakMap }) getName(item) { return item.name; }
@Memoize('getName') getLastName(item) { return item.lastName; } }
variable Memoize
const Memoize: BiTypedMethodDecorator1<string | Function | MemoizeConfig<any, any>>;
Creates a function that memoizes the result of func. If resolver is provided, it determines the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the map cache key. The func is invoked with the this binding of the memoized function.
You can use a Function or a string that references a method on the class as the resolver. You can also use a configuration object that lets provide a prexisting cache or specify the map type to use.
Example 1
class MyClass { @Memoize({ type: WeakMap }) getName(item) { return item.name; }
@Memoize('getName') getLastName(item) { return item.lastName; } }
variable memoizeAll
const memoizeAll: BiTypedMethodDecorator1<Function | MemoizeConfig<any, any>>;
Memoizes a function on the prototype instead of the instance. All instances of the class use the same memoize cache.
Parameter resolver
Optional resolver
variable MemoizeAll
const MemoizeAll: BiTypedMethodDecorator1<Function | MemoizeConfig<any, any>>;
Memoizes a function on the prototype instead of the instance. All instances of the class use the same memoize cache.
Parameter resolver
Optional resolver
variable negate
const negate: BiTypedDecorator1<ResolvableFunction>;
Negates a functions result or, when used on a property, creates a function that negates the result of a provided function.
Parameter fn
A resolvable function.
Example 1
class MyClass { @Negate('fn') fn2: () => boolean;
fn(): boolean { return true; } }
const myClass = new MyClass();
myClass.fn2(); //=> false
variable Negate
const Negate: BiTypedDecorator1<ResolvableFunction>;
Negates a functions result or, when used on a property, creates a function that negates the result of a provided function.
Parameter fn
A resolvable function.
Example 1
class MyClass { @Negate('fn') fn2: () => boolean;
fn(): boolean { return true; } }
const myClass = new MyClass();
myClass.fn2(); //=> false
variable once
const once: BiTypedDecorator;
Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.
Example 1
class MyClass { value: number = 0;
@Once() fn(): number { return ++this.value; } }
const myClass = new MyClass();
myClass.fn(); //=> 1 myClass.fn(); //=> 1 myClass.fn(); //=> 1
variable Once
const Once: BiTypedDecorator;
Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.
Example 1
class MyClass { value: number = 0;
@Once() fn(): number { return ++this.value; } }
const myClass = new MyClass();
myClass.fn(); //=> 1 myClass.fn(); //=> 1 myClass.fn(); //=> 1
variable rest
const rest: BiTypedMethodDecorator1<number>;
variable Rest
const Rest: BiTypedMethodDecorator1<number>;
variable spread
const spread: BiTypedMethodDecorator1<number>;
variable Spread
const Spread: BiTypedMethodDecorator1<number>;
variable tap
const tap: BiTypedMethodDecorator;
Returns the first argument from the function regardless of the decorated functions return value.
variable Tap
const Tap: BiTypedMethodDecorator;
Returns the first argument from the function regardless of the decorated functions return value.
variable throttle
const throttle: BiTypedDecorator2<number, ThrottleOptions>;
variable Throttle
const Throttle: BiTypedDecorator2<number, ThrottleOptions>;
variable throttleGetter
const throttleGetter: BiTypedDecorator2<number, ThrottleOptions>;
variable ThrottleGetter
const ThrottleGetter: BiTypedDecorator2<number, ThrottleOptions>;
variable throttleSetter
const throttleSetter: BiTypedDecorator2<number, ThrottleOptions>;
variable ThrottleSetter
const ThrottleSetter: BiTypedDecorator2<number, ThrottleOptions>;
variable unary
const unary: BiTypedMethodDecorator;
variable Unary
const Unary: BiTypedMethodDecorator;
Functions
function after
after: (n: number) => LodashDecorator;
The opposite of Before. This method creates a function that invokes once it's called n or more times.
Parameter n
The number of calls before the function is invoked.
Example 1
class MyClass { @After(2) fn() { return 10; } }
const myClass = new MyClass();
myClass.fn(); // => undefined myClass.fn(); // => 10
function After
After: (n: number) => LodashDecorator;
The opposite of Before. This method creates a function that invokes once it's called n or more times.
Parameter n
The number of calls before the function is invoked.
Example 1
class MyClass { @After(2) fn() { return 10; } }
const myClass = new MyClass();
myClass.fn(); // => undefined myClass.fn(); // => 10
function afterAll
afterAll: (n: number) => LodashDecorator;
The opposite of Before. This method creates a function that invokes once it's called n or more times. This spans across all instances of the class instead of the instance.
Parameter n
The number of calls before the function is invoked.
Example 1
class MyClass { @AfterAll(2) fn() { return 10; } }
const myClass = new MyClass(); const myClass2 = new MyClass();
myClass.fn(); // => undefined myClass.fn(); // => 10
myClass2.fn(); // => 10 myClass2.fn(); // => 10
function AfterAll
AfterAll: (n: number) => LodashDecorator;
The opposite of Before. This method creates a function that invokes once it's called n or more times. This spans across all instances of the class instead of the instance.
Parameter n
The number of calls before the function is invoked.
Example 1
class MyClass { @AfterAll(2) fn() { return 10; } }
const myClass = new MyClass(); const myClass2 = new MyClass();
myClass.fn(); // => undefined myClass.fn(); // => 10
myClass2.fn(); // => 10 myClass2.fn(); // => 10
function ary
ary: (n: number) => LodashMethodDecorator;
Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
Parameter n
The arity cap.
Example 1
class MyClass { @Ary(1) fn(...args) { return args; } }
const myClass = new MyClass();
myClass.fn(1, 2, 3, 4); // => [ 1 ]
function Ary
Ary: (n: number) => LodashMethodDecorator;
Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
Parameter n
The arity cap.
Example 1
class MyClass { @Ary(1) fn(...args) { return args; } }
const myClass = new MyClass();
myClass.fn(1, 2, 3, 4); // => [ 1 ]
function before
before: (n: number) => LodashDecorator;
Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times. Subsequent calls to the created function return the result of the last func invocation.
Parameter n
The number of calls at whichc func is no longer invoked.
Example 1
let calls = 0;
class MyClass { @Before(3) fn() { calls++; } }
const myClass = new MyClass();
myClass.fn(); myClass.fn(); myClass.fn(); myClass.fn();
calls === 2; // => true
function Before
Before: (n: number) => LodashDecorator;
Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times. Subsequent calls to the created function return the result of the last func invocation.
Parameter n
The number of calls at whichc func is no longer invoked.
Example 1
let calls = 0;
class MyClass { @Before(3) fn() { calls++; } }
const myClass = new MyClass();
myClass.fn(); myClass.fn(); myClass.fn(); myClass.fn();
calls === 2; // => true
function beforeAll
beforeAll: (n: number) => LodashDecorator;
Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times. Subsequent calls to the created function return the result of the last func invocation.
Parameter n
The number of calls at whichc func is no longer invoked.
Example 1
let calls = 0;
class MyClass { @BeforeAll(3) fn() { calls++; } }
const myClass = new MyClass(); const myClass2 = new MyClass();
myClass.fn(); myClass.fn(); myClass.fn(); myClass.fn();
myClass2.fn();
calls === 3; // => true
function BeforeAll
BeforeAll: (n: number) => LodashDecorator;
Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times. Subsequent calls to the created function return the result of the last func invocation.
Parameter n
The number of calls at whichc func is no longer invoked.
Example 1
let calls = 0;
class MyClass { @BeforeAll(3) fn() { calls++; } }
const myClass = new MyClass(); const myClass2 = new MyClass();
myClass.fn(); myClass.fn(); myClass.fn(); myClass.fn();
myClass2.fn();
calls === 3; // => true
function bindAll
bindAll: (methods?: string[]) => ClassDecorator;
Binds methods of an object to the object itself, overwriting the existing method.
Parameter methods
Returns
{ClassDecorator}
Example 1
@BindAll() class MyClass { bound() { return this; }
unbound() { return this; } }
const myClass = new MyClass();
myClass.bound.call(null); // => MyClass {} myClass.unbound.call(null); // => MyClass {}
function BindAll
BindAll: (methods?: string[]) => ClassDecorator;
Binds methods of an object to the object itself, overwriting the existing method.
Parameter methods
Returns
{ClassDecorator}
Example 1
@BindAll() class MyClass { bound() { return this; }
unbound() { return this; } }
const myClass = new MyClass();
myClass.bound.call(null); // => MyClass {} myClass.unbound.call(null); // => MyClass {}
function debounce
debounce: (wait?: number, options?: DebounceOptions) => LodashDecorator;
Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function. Subsequent calls to the debounced function return the result of the last func invocation.
Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.
If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.
Parameter wait
The number in milliseconds to delay.
Parameter options
The options object.
Example 1
class MyClass { value = 100;
@Debounce(10) add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10); myClass.add(50); myClass.add(20);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 120; }, 11);
function Debounce
Debounce: (wait?: number, options?: DebounceOptions) => LodashDecorator;
Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function. Subsequent calls to the debounced function return the result of the last func invocation.
Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.
If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.
Parameter wait
The number in milliseconds to delay.
Parameter options
The options object.
Example 1
class MyClass { value = 100;
@Debounce(10) add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10); myClass.add(50); myClass.add(20);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 120; }, 11);
function debounceAll
debounceAll: (wait?: number, options?: DebounceOptions) => LodashMethodDecorator;
Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function. Subsequent calls to the debounced function return the result of the last func invocation.
The debounce state is shared across all instances of the class.
Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.
If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.
Parameter wait
The number in milliseconds to delay.
Parameter options
The options object.
Example 1
class MyClass { value = 100;
@DebounceAll(10) add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10); myClass.add(50); myClass.add(20);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 120; }, 11);
function DebounceAll
DebounceAll: (wait?: number, options?: DebounceOptions) => LodashMethodDecorator;
Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a cancel method to cancel delayed func invocations and a flush method to immediately invoke them. Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. The func is invoked with the last arguments provided to the debounced function. Subsequent calls to the debounced function return the result of the last func invocation.
The debounce state is shared across all instances of the class.
Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the wait timeout.
If wait is 0 and leading is false, func invocation is deferred until to the next tick, similar to setTimeout with a timeout of 0.
Parameter wait
The number in milliseconds to delay.
Parameter options
The options object.
Example 1
class MyClass { value = 100;
@DebounceAll(10) add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10); myClass.add(50); myClass.add(20);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 120; }, 11);
function delay
delay: (wait: number, ...args: any[]) => LodashMethodDecorator;
Invokes func after wait milliseconds. Any additional arguments are provided to func when it's invoked.
Parameter wait
The number of milliseconds to delay invocation.
Parameter args
Additional arguments to invoke the function with
Example 1
class MyClass { value = 100;
@Delay(20) add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 110; }, 30);
function Delay
Delay: (wait: number, ...args: any[]) => LodashMethodDecorator;
Invokes func after wait milliseconds. Any additional arguments are provided to func when it's invoked.
Parameter wait
The number of milliseconds to delay invocation.
Parameter args
Additional arguments to invoke the function with
Example 1
class MyClass { value = 100;
@Delay(20) add(a) { this.value += a; } }
const myClass = new MyClass();
myClass.add(10);
myClass.value; // => 100;
setTimeout(() => { myClass.value; // => 110; }, 30);
function flip
flip: (fn?: ResolvableFunction) => LodashDecorator;
Creates a function that invokes func with arguments reversed. Honestly, there is probably not much use for this decorator but maybe you will find one?
Example 1
class MyClass { value = 100;
@Flip('fn') fn2: (b: number, a: string) => [ number, string ];
fn(a: string, b: number): [ string, number ] { return [ a, b ]; } }
const myClass = new MyClass();
myClass.fn2(10, '20'); // => [ '20', 10 ]
function Flip
Flip: (fn?: ResolvableFunction) => LodashDecorator;
Creates a function that invokes func with arguments reversed. Honestly, there is probably not much use for this decorator but maybe you will find one?
Example 1
class MyClass { value = 100;
@Flip('fn') fn2: (b: number, a: string) => [ number, string ];
fn(a: string, b: number): [ string, number ] { return [ a, b ]; } }
const myClass = new MyClass();
myClass.fn2(10, '20'); // => [ '20', 10 ]
function flow
flow: (...fns: ResolvableFunction[]) => LodashDecorator;
Creates a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.
Example 1
class MyClass { name = 'Ted';
@Flow('getName', toUpperCase) getUpperCaseName: () => string;
getName() { return this.name; } }
const myClass = new MyClass();
myClass.getUpperCaseName(); // => 'TED'
function Flow
Flow: (...fns: ResolvableFunction[]) => LodashDecorator;
Creates a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.
Example 1
class MyClass { name = 'Ted';
@Flow('getName', toUpperCase) getUpperCaseName: () => string;
getName() { return this.name; } }
const myClass = new MyClass();
myClass.getUpperCaseName(); // => 'TED'
function flowRight
flowRight: (...fns: ResolvableFunction[]) => LodashDecorator;
Creates a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.
Example 1
class MyClass { name = 'Ted';
@FlowRight(toUpperCase, 'getName') getUpperCaseName: () => string;
getName() { return this.name; } }
const myClass = new MyClass();
myClass.getUpperCaseName(); // => 'TED'
function FlowRight
FlowRight: (...fns: ResolvableFunction[]) => LodashDecorator;
Creates a function that returns the result of invoking the given functions with the this binding of the created function, where each successive invocation is supplied the return value of the previous.
Example 1
class MyClass { name = 'Ted';
@FlowRight(toUpperCase, 'getName') getUpperCaseName: () => string;
getName() { return this.name; } }
const myClass = new MyClass();
myClass.getUpperCaseName(); // => 'TED'
function mixin
mixin: (...srcs: Object[]) => ClassDecorator;
Mixins an object into the classes prototype.
Parameter srcs
Returns
{ClassDecorator}
Example 1
const myMixin = { blorg: () => 'blorg!' }
@Mixin(myMixin) class MyClass {}
const myClass = new MyClass();
myClass.blorg(); // => 'blorg!'
function Mixin
Mixin: (...srcs: Object[]) => ClassDecorator;
Mixins an object into the classes prototype.
Parameter srcs
Returns
{ClassDecorator}
Example 1
const myMixin = { blorg: () => 'blorg!' }
@Mixin(myMixin) class MyClass {}
const myClass = new MyClass();
myClass.blorg(); // => 'blorg!'
function overArgs
overArgs: (...transforms: Function[]) => LodashMethodDecorator;
Creates a function that invokes func with its arguments transformed.
Parameter transforms
Returns
{LodashMethodDecorator}
Example 1
class MyClass { @OverArgs(_.castArray) fn(list) { return list; } }
const myClass = new MyClass();
myClass.fn([ 1 ]); //=> [ 1 ]; myClass.fn(1); //=> [ 1 ];
function OverArgs
OverArgs: (...transforms: Function[]) => LodashMethodDecorator;
Creates a function that invokes func with its arguments transformed.
Parameter transforms
Returns
{LodashMethodDecorator}
Example 1
class MyClass { @OverArgs(_.castArray) fn(list) { return list; } }
const myClass = new MyClass();
myClass.fn([ 1 ]); //=> [ 1 ]; myClass.fn(1); //=> [ 1 ];
function partial
partial: (...partials: any[]) => PropertyDecorator;
Partially applies arguments to a function.
Parameter partials
Returns
{PropertyDecorator}
Example 1
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
Partial: (...partials: any[]) => PropertyDecorator;
Partially applies arguments to a function.
Parameter partials
Returns
{PropertyDecorator}
Example 1
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 partialRight
partialRight: (...partials: any[]) => PropertyDecorator;
function PartialRight
PartialRight: (...partials: any[]) => PropertyDecorator;
function rearg
rearg: ( indexes: ResolvableFunction | number | number[], ...args: Array<number | number[]>) => LodashDecorator;
function Rearg
Rearg: ( indexes: ResolvableFunction | number | number[], ...args: Array<number | number[]>) => LodashDecorator;
function throttleAll
throttleAll: (wait?: number, options?: ThrottleOptions) => LodashMethodDecorator;
function ThrottleAll
ThrottleAll: (wait?: number, options?: ThrottleOptions) => LodashMethodDecorator;
function wrap
wrap: (fnToWrap?: ResolvableFunction) => LodashMethodDecorator;
function Wrap
Wrap: (fnToWrap?: ResolvableFunction) => LodashMethodDecorator;
Classes
class DecoratorConfig
class DecoratorConfig {}
constructor
constructor( execute: Function, applicator: Applicator, options?: DecoratorConfigOptions);
property applicator
readonly applicator: Applicator;
property bound
readonly bound: boolean;
property execute
readonly execute: Function;
property getter
readonly getter: boolean;
property method
readonly method: boolean;
property optionalParams
readonly optionalParams: boolean;
property options
readonly options: DecoratorConfigOptions;
property property
readonly property: boolean;
property setter
readonly setter: boolean;
class InternalDecoratorFactory
class InternalDecoratorFactory {}
method createDecorator
createDecorator: (config: DecoratorConfig) => GenericDecorator;
method createInstanceDecorator
createInstanceDecorator: (config: DecoratorConfig) => GenericDecorator;
Interfaces
interface DecoratorConfigOptions
interface DecoratorConfigOptions {}
interface InstanceChainContext
interface InstanceChainContext {}
interface InstanceChainData
interface InstanceChainData {}
property fns
fns: Function[];
property isGetter
isGetter: boolean;
property isMethod
isMethod: boolean;
property isProperty
isProperty: boolean;
property isSetter
isSetter: boolean;
property properties
properties: string[];
Type Aliases
type ApplicatorToken
type ApplicatorToken = { new (): Applicator;};
type BiTypedDecorator
type BiTypedDecorator = (() => LodashDecorator) & LodashDecorator;
type BiTypedDecorator1
type BiTypedDecorator1<T> = ((arg?: T) => LodashDecorator) & LodashDecorator;
type BiTypedDecorator2
type BiTypedDecorator2<T, T2> = ((arg1?: T, arg2?: T2) => LodashDecorator) & LodashDecorator;
type BiTypedDecorator3
type BiTypedDecorator3<T, T2, T3> = (( arg1?: T, arg2?: T2, arg3?: T3) => LodashDecorator) & LodashDecorator;
type BiTypedDecoratorN
type BiTypedDecoratorN = ((...args: any[]) => LodashDecorator) & LodashDecorator;
type BiTypedMethodDecorator
type BiTypedMethodDecorator = (() => LodashMethodDecorator) & LodashMethodDecorator;
type BiTypedMethodDecorator1
type BiTypedMethodDecorator1<T> = ((arg?: T) => LodashMethodDecorator) & LodashMethodDecorator;
type BiTypedMethodDecorator2
type BiTypedMethodDecorator2<T, T2> = (( arg1?: T, arg2?: T2) => LodashMethodDecorator) & LodashMethodDecorator;
type BiTypedMethodDecorator3
type BiTypedMethodDecorator3<T, T2, T3> = (( arg1?: T, arg2?: T2, arg3?: T3) => LodashMethodDecorator) & LodashMethodDecorator;
type BiTypedMethodDecoratorN
type BiTypedMethodDecoratorN = ((...args: any[]) => LodashMethodDecorator) & LodashMethodDecorator;
type GenericDecorator
type GenericDecorator = (...args: any[]) => LodashDecorator;
type LodashDecorator
type LodashDecorator = MethodDecorator & PropertyDecorator;
type LodashMethodDecorator
type LodashMethodDecorator = MethodDecorator;
type ResolvableFunction
type ResolvableFunction = string | Function;
Package Files (39)
- after.d.ts
- afterAll.d.ts
- ary.d.ts
- attempt.d.ts
- before.d.ts
- beforeAll.d.ts
- bind.d.ts
- bindAll.d.ts
- curry.d.ts
- curryAll.d.ts
- curryRight.d.ts
- curryRightAll.d.ts
- debounce.d.ts
- debounceAll.d.ts
- defer.d.ts
- delay.d.ts
- factory/DecoratorConfig.d.ts
- factory/DecoratorFactory.d.ts
- factory/common.d.ts
- flip.d.ts
- flow.d.ts
- flowRight.d.ts
- index.d.ts
- memoize.d.ts
- memoizeAll.d.ts
- mixin.d.ts
- negate.d.ts
- once.d.ts
- overArgs.d.ts
- partial.d.ts
- partialRight.d.ts
- rearg.d.ts
- rest.d.ts
- spread.d.ts
- tap.d.ts
- throttle.d.ts
- throttleAll.d.ts
- unary.d.ts
- wrap.d.ts
Dependencies (1)
Dev Dependencies (18)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/lodash-decorators
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/lodash-decorators)
- HTML<a href="https://www.jsdocs.io/package/lodash-decorators"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3295 ms. - Missing or incorrect documentation? Open an issue for this package.