Options
All
  • Public
  • Public/Protected
  • All
Menu

Module curry

Index

References

Functions Function

References

Renames and re-exports curry

Function Functions

  • curry<T>(func: T, arity?: number, guard?: any): CurriedFunction
  • 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.

    Note: This method doesn't set the "length" property of curried functions.

    since

    5.5.0

    example
    var abc = function(a, b, c) {
    return [a, b, c];
    };

    var curried = curry(abc);

    curried(1)(2)(3);
    // => [1, 2, 3]

    curried(1, 2)(3);
    // => [1, 2, 3]

    curried(1, 2, 3);
    // => [1, 2, 3]

    // Curried with placeholders.
    curried(1)(curry.placeholder, 3)(2);
    // => [1, 2, 3]

    Type Parameters

    • T extends Function = any

    Parameters

    • func: T

      The function to curry.

    • arity: number = func.length

      The arity of func.

    • Optional guard: any

      Enables use as an iteratee for methods like map.

    Returns CurriedFunction

    Returns the new curried function.