Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • LoDashStatic

Index

Properties

bind

Creates a function that invokes func with the this binding of thisArg and prepends any additional _.bind arguments to those provided to the bound function.

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 does not set the "length" property of bound functions.

param

The function to bind.

param

The this binding of func.

param

The arguments to be partially applied.

returns

Returns the new bound function.

bindKey

Creates a function that invokes the method at object[key] and prepends any additional _.bindKey arguments to those provided to the bound function.

This method differs from _.bind by allowing bound functions to reference methods that may be redefined or don’t yet exist. See Peter Michaux’s article for more details.

The _.bindKey.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for partially applied arguments.

param

The object the method belongs to.

param

The key of the method.

param

The arguments to be partially applied.

returns

Returns the new bound function.

curry

curry: Curry

curryRight

curryRight: CurryRight

memoize

memoize: object

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 coerced to a string and used as the cache key. The func is invoked with the this binding of the memoized function.

param

The function to have its output memoized.

param

The function to resolve the cache key.

returns

Returns the new memoizing function.

Type declaration

partial

partial: Partial

Creates a function that, when called, invokes func with any additional partial arguments prepended to those provided to the new function. This method is similar to _.bind except it does not alter the this binding.

param

The function to partially apply arguments to.

param

Arguments to be partially applied.

returns

The new partially applied function.

partialRight

partialRight: PartialRight

This method is like _.partial except that partial arguments are appended to those provided to the new function.

param

The function to partially apply arguments to.

param

Arguments to be partially applied.

returns

The new partially applied function.

Methods

after

  • after<TFunc>(n: number, func: TFunc): TFunc
  • The opposite of _.before; this method creates a function that invokes func once it’s called n or more times.

    Type parameters

    • TFunc: function

    Parameters

    • n: number

      The number of calls before func is invoked.

    • func: TFunc

      The function to restrict.

    Returns TFunc

    Returns the new restricted function.

ary

  • ary(func: function, n?: undefined | number): function
  • Creates a function that accepts up to n arguments ignoring any additional arguments.

    Parameters

    • func: function

      The function to cap arguments for.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional n: undefined | number

      The arity cap.

    Returns function

    Returns the new function.

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

before

  • before<TFunc>(n: number, func: TFunc): TFunc
  • 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.

    Type parameters

    • TFunc: function

    Parameters

    • n: number

      The number of calls at which func is no longer invoked.

    • func: TFunc

      The function to restrict.

    Returns TFunc

    Returns the new restricted function.

debounce

  • 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 invocations and a flush method to immediately invoke them. Provide an options object to indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. 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 the debounced function is invoked more than once during the wait timeout.

    See David Corbacho’s article for details over the differences between _.debounce and _.throttle.

    Type parameters

    • T: function

    Parameters

    • func: T

      The function to debounce.

    • Optional wait: undefined | number

      The number of milliseconds to delay.

    • Optional options: DebounceSettings

      The options object.

    Returns T & Cancelable

    Returns the new debounced function.

defer

  • defer(func: function, ...args: any[]): number
  • Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it’s invoked.

    Parameters

    • func: function

      The function to defer.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Rest ...args: any[]

      The arguments to invoke the function with.

    Returns number

    Returns the timer id.

delay

  • delay(func: function, wait: number, ...args: any[]): number
  • Invokes func after wait milliseconds. Any additional arguments are provided to func when it’s invoked.

    Parameters

    • func: function

      The function to delay.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • wait: number

      The number of milliseconds to delay invocation.

    • Rest ...args: any[]

      The arguments to invoke the function with.

    Returns number

    Returns the timer id.

flip

  • flip<T>(func: T): T
  • Creates a function that invokes func with arguments reversed.

    category

    Function

    example

    var flipped = _.flip(function() { return _.toArray(arguments); });

    flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a']

    Type parameters

    • T: function

    Parameters

    • func: T

      The function to flip arguments for.

    Returns T

    Returns the new function.

negate

  • negate(predicate: function): function
  • negate<A1>(predicate: function): function
  • negate<A1, A2>(predicate: function): function
  • negate(predicate: function): function
  • Creates a function that negates the result of the predicate func. The func predicate is invoked with the this binding and arguments of the created function.

    Parameters

    • predicate: function

      The predicate to negate.

        • (): boolean
        • Returns boolean

    Returns function

    Returns the new function.

      • (): boolean
      • Returns boolean

  • Type parameters

    • A1

    Parameters

    • predicate: function
        • (a1: A1): boolean
        • Parameters

          • a1: A1

          Returns boolean

    Returns function

      • (a1: A1): boolean
      • Parameters

        • a1: A1

        Returns boolean

  • Type parameters

    • A1

    • A2

    Parameters

    • predicate: function
        • (a1: A1, a2: A2): boolean
        • Parameters

          • a1: A1
          • a2: A2

          Returns boolean

    Returns function

      • (a1: A1, a2: A2): boolean
      • Parameters

        • a1: A1
        • a2: A2

        Returns boolean

  • Parameters

    • predicate: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns function

      • (...args: any[]): boolean
      • Parameters

        • Rest ...args: any[]

        Returns boolean

once

  • once<T>(func: T): T
  • Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first call. The func is invoked with the this binding and arguments of the created function.

    Type parameters

    • T: function

    Parameters

    • func: T

      The function to restrict.

    Returns T

    Returns the new restricted function.

overArgs

  • overArgs(func: function, ...transforms: Array<Many<function>>): function
  • Creates a function that runs each argument through a corresponding transform function.

    Parameters

    • func: function

      The function to wrap.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Rest ...transforms: Array<Many<function>>

      The functions to transform arguments, specified as individual functions or arrays of functions.

    Returns function

    Returns the new function.

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

rearg

  • rearg(func: function, ...indexes: Array<Many<number>>): function
  • Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.

    Parameters

    • func: function

      The function to rearrange arguments for.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Rest ...indexes: Array<Many<number>>

      The arranged argument indexes, specified as individual indexes or arrays of indexes.

    Returns function

    Returns the new function.

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

rest

  • rest(func: function, start?: undefined | number): function
  • Creates a function that invokes func with the this binding of the created function and arguments from start and beyond provided as an array.

    Note: This method is based on the rest parameter.

    Parameters

    • func: function

      The function to apply a rest parameter to.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional start: undefined | number

      The start position of the rest parameter.

    Returns function

    Returns the new function.

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

spread

  • spread<TResult>(func: function): function
  • spread<TResult>(func: function, start: number): function
  • Creates a function that invokes func with the this binding of the created function and an array of arguments much like Function#apply.

    Note: This method is based on the spread operator.

    Type parameters

    • TResult

    Parameters

    • func: function

      The function to spread arguments over.

        • (...args: any[]): TResult
        • Parameters

          • Rest ...args: any[]

          Returns TResult

    Returns function

    Returns the new function.

      • (...args: any[]): TResult
      • Parameters

        • Rest ...args: any[]

        Returns TResult

  • see

    _.spread

    Type parameters

    • TResult

    Parameters

    • func: function
        • (...args: any[]): TResult
        • Parameters

          • Rest ...args: any[]

          Returns TResult

    • start: number

    Returns function

      • (...args: any[]): TResult
      • Parameters

        • Rest ...args: any[]

        Returns TResult

throttle

  • Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled function comes with a cancel method to cancel delayed invocations and a flush method to immediately invoke them. Provide an options object to indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled function return the result of the last func call.

    Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if the the throttled function is invoked more than once during the wait timeout.

    Type parameters

    • T: function

    Parameters

    • func: T

      The function to throttle.

    • Optional wait: undefined | number

      The number of milliseconds to throttle invocations to.

    • Optional options: ThrottleSettings

      The options object.

    Returns T & Cancelable

    Returns the new throttled function.

unary

  • unary<T, TResult>(func: function): function
  • Creates a function that accepts up to one argument, ignoring any additional arguments.

    category

    Function

    example

    _.map(['6', '8', '10'], _.unary(parseInt)); // => [6, 8, 10]

    Type parameters

    • T

    • TResult

    Parameters

    • func: function

      The function to cap arguments for.

        • (arg1: T, ...args: any[]): TResult
        • Parameters

          • arg1: T
          • Rest ...args: any[]

          Returns TResult

    Returns function

    Returns the new function.

      • (arg1: T): TResult
      • Parameters

        • arg1: T

        Returns TResult

wrap

  • wrap<T, TArgs, TResult>(value: T, wrapper: function): function
  • wrap<T, TResult>(value: T, wrapper: function): function
  • Creates a function that provides value to the wrapper function as its first argument. Any additional arguments provided to the function are appended to those provided to the wrapper function. The wrapper is invoked with the this binding of the created function.

    Type parameters

    • T

    • TArgs

    • TResult

    Parameters

    • value: T

      The value to wrap.

    • wrapper: function

      The wrapper function.

        • (value: T, ...args: TArgs[]): TResult
        • Parameters

          • value: T
          • Rest ...args: TArgs[]

          Returns TResult

    Returns function

    Returns the new function.

      • (...args: TArgs[]): TResult
      • Parameters

        • Rest ...args: TArgs[]

        Returns TResult

  • see

    _.wrap

    Type parameters

    • T

    • TResult

    Parameters

    • value: T
    • wrapper: function
        • (value: T, ...args: any[]): TResult
        • Parameters

          • value: T
          • Rest ...args: any[]

          Returns TResult

    Returns function

      • (...args: any[]): TResult
      • Parameters

        • Rest ...args: any[]

        Returns TResult

Generated using TypeDoc