Home Reference Source Test Repository

Variable

Static Public Summary
public

After(n: number): *

The opposite of Before.

public

AfterAll(n: number): *

The opposite of Before.

public

Ary(n: number): *

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

Before(n: number): *

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

BeforeAll(n: number): *

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

Curry(arity: 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.

public

CurryAll(arity: 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.

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

Debounce(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

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

Delay(wait: number, args: ...*): *

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

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
public

Partial: *

public
public

Rearg: *

public

Rest: *

public

Spread: *

public

Tap: *

Returns the first argument from the function regardless of the decorated functions return value.

public
public
public
public
public

Unary: *

public

Wrap: *

Static Public

public After(n: number): * source

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

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

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

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

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

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

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

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

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

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

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

public Defer(args: ...*): * source

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

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

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

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

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 Memoize: * source

public MemoizeAll(resolver: Function): * source

Memoizes a function on the prototype instead of the instance. All instances of the class use the same memoize cache.

public Negate: * source

public Once: * source

public OnceAll: * source

public OverArgs: * source

public Partial: * source

public PartialRight: * source

import {PartialRight} from 'lodash-decorators/buildDocs/partialRight.js'

public Rearg: * source

public Rest: * source

public Spread: * source

public Tap: * source

Returns the first argument from the function regardless of the decorated functions return value.

public Throttle: * source

public ThrottleAll: * source

import {ThrottleAll} from 'lodash-decorators/buildDocs/throttleAll.js'

public ThrottleGetter: * source

import {ThrottleGetter} from 'lodash-decorators/buildDocs/throttle.js'

public ThrottleSetter: * source

import {ThrottleSetter} from 'lodash-decorators/buildDocs/throttle.js'

public Unary: * source

public Wrap: * source