Variable
Static Public Summary | ||
public |
The opposite of Before. |
|
public |
The opposite of Before. |
|
public |
Creates a function that invokes func, with up to n arguments, ignoring any additional arguments. |
|
public |
Attempt(args: ...*): * Attempts to invoke func, returning either the result or the caught error object. |
|
public |
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. |
|
public |
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. |
|
public |
Bind(partials: ...*): * Creates a function that invokes func with the this binding of thisArg and partials prepended to the arguments it receives. |
|
public |
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. |
|
public |
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. |
|
public |
CurryRight(arity: number): * This method is like .curry except that arguments are applied to func in the manner of .partialRight instead of _.partial. |
|
public |
CurryRightAll(arity: number): * This method is like .curry except that arguments are applied to func in the manner of .partialRight instead of _.partial. |
|
public |
Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. |
|
public |
DebounceAll(wait: number, options: DebounceOptions): * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. |
|
public |
|
|
public |
Defer(args: ...*): * Defers invoking the func until the current call stack has cleared. |
|
public |
Invokes func after wait milliseconds. |
|
public |
Flip: * Creates a function that invokes func with arguments reversed. |
|
public |
Flow: * 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. |
|
public |
FlowRight: * 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. |
|
public |
InstanceChainMap: buildDocs/utils.js~CompositeKeyWeakMap |
|
public |
Memoize: * |
|
public |
MemoizeAll(resolver: Function): * Memoizes a function on the prototype instead of the instance. |
|
public |
Negate: * |
|
public |
Once: * |
|
public |
OnceAll: * |
|
public |
OverArgs: * |
|
public |
Partial: * |
|
public |
PartialRight: * |
|
public |
Rearg: * |
|
public |
Rest: * |
|
public |
Spread: * |
|
public |
Tap: * Returns the first argument from the function regardless of the decorated functions return value. |
|
public |
Throttle: * |
|
public |
ThrottleAll: * |
|
public |
|
|
public |
|
|
public |
Unary: * |
|
public |
Wrap: * |
Static Public
public After(n: number): * source
import {After} from 'lodash-decorators/buildDocs/after.js'
The opposite of Before. This method creates a function that invokes once it's called n or more times.
Example:
class MyClass {
@After(2)
fn() {
return 10;
}
}
const myClass = new MyClass();
myClass.fn(); // => undefined
myClass.fn(); // => 10
public AfterAll(n: number): * source
import {AfterAll} from 'lodash-decorators/buildDocs/afterAll.js'
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.
Example:
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
public Ary(n: number): * source
import {Ary} from 'lodash-decorators/buildDocs/ary.js'
Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.
Example:
class MyClass {
@Ary(1)
fn(...args) {
return args;
}
}
const myClass = new MyClass();
myClass.fn(1, 2, 3, 4); // => [ 1 ]
public Attempt(args: ...*): * source
import {Attempt} from 'lodash-decorators/buildDocs/attempt.js'
Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked.
Example:
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
public Before(n: number): * source
import {Before} from 'lodash-decorators/buildDocs/before.js'
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.
Example:
let calls = 0;
class MyClass {
@Before(3)
fn() {
calls++;
}
}
const myClass = new MyClass();
myClass.fn();
myClass.fn();
myClass.fn();
myClass.fn();
calls === 2; // => true
public BeforeAll(n: number): * source
import {BeforeAll} from 'lodash-decorators/buildDocs/beforeAll.js'
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.
Example:
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
public Bind(partials: ...*): * source
import {Bind} from 'lodash-decorators/buildDocs/bind.js'
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.
Example:
class MyClass {
@Bind()
bound() {
return this;
}
unbound() {
return this;
}
}
const myClass = new MyClass();
myClass.bound.call(null); // => myClass {}
myClass.unbound.call(null); // => null
public Curry(arity: number): * source
import {Curry} from 'lodash-decorators/buildDocs/curry.js'
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.
Example:
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
public CurryAll(arity: number): * source
import {CurryAll} from 'lodash-decorators/buildDocs/curryAll.js'
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.
Example:
class MyClass {
@CurryAll()
add(a, b) {
return (a + b);
}
}
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 15
public CurryRight(arity: number): * source
import {CurryRight} from 'lodash-decorators/buildDocs/curryRight.js'
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.
Example:
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
public CurryRightAll(arity: number): * source
import {CurryRightAll} from 'lodash-decorators/buildDocs/curryRightAll.js'
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.
Example:
class MyClass {
@CurryRightAll()
add(a, b) {
return (a + b);
}
}
const myClass = new MyClass();
const add5 = myClass.add(5);
add5AndMultiply(10); // => 15
public Debounce(wait: number, options: DebounceOptions): * source
import {Debounce} from 'lodash-decorators/buildDocs/debounce.js'
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.
Example:
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);
public DebounceAll(wait: number, options: DebounceOptions): * source
import {DebounceAll} from 'lodash-decorators/buildDocs/debounceAll.js'
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.
Example:
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);
public DecoratorFactory: InternalDecoratorFactory source
import {DecoratorFactory} from 'lodash-decorators/buildDocs/factory/DecoratorFactory.js'
public Defer(args: ...*): * source
import {Defer} from 'lodash-decorators/buildDocs/defer.js'
Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.
Example:
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);
public Delay(wait: number, args: ...*): * source
import {Delay} from 'lodash-decorators/buildDocs/delay.js'
Invokes func after wait milliseconds. Any additional arguments are provided to func when it's invoked.
Example:
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);
public Flip: * source
import {Flip} from 'lodash-decorators/buildDocs/flip.js'
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:
class MyClass {
value = 100;
@Flip()
fn(a, b) {
return [ a, b ];
}
}
const myClass = new MyClass();
myClass.fn(10, 20); // => [ 20, 10 ]
public Flow: * source
import {Flow} from 'lodash-decorators/buildDocs/flow.js'
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:
class MyClass {
name = 'Ted';
@Flow('getName', toUpperCase)
getUpperCaseName: () => string;
getName() {
return this.name;
}
}
const myClass = new MyClass();
myClass.getUpperCaseName(); // => 'TED'
public FlowRight: * source
import {FlowRight} from 'lodash-decorators/buildDocs/flowRight.js'
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:
class MyClass {
name = 'Ted';
@FlowRight(toUpperCase, 'getName')
getUpperCaseName: () => string;
getName() {
return this.name;
}
}
const myClass = new MyClass();
myClass.getUpperCaseName(); // => 'TED'
public InstanceChainMap: buildDocs/utils.js~CompositeKeyWeakMap source
import {InstanceChainMap} from 'lodash-decorators/buildDocs/factory/common.js'
public MemoizeAll(resolver: Function): * source
import {MemoizeAll} from 'lodash-decorators/buildDocs/memoizeAll.js'
Memoizes a function on the prototype instead of the instance. All instances of the class use the same memoize cache.
public PartialRight: * source
import {PartialRight} from 'lodash-decorators/buildDocs/partialRight.js'
public Tap: * source
import {Tap} from 'lodash-decorators/buildDocs/tap.js'
Returns the first argument from the function regardless of the decorated functions return value.
public ThrottleGetter: * source
import {ThrottleGetter} from 'lodash-decorators/buildDocs/throttle.js'
public ThrottleSetter: * source
import {ThrottleSetter} from 'lodash-decorators/buildDocs/throttle.js'