UNPKG

super-utils-plus

Version:

A superior alternative to Lodash with improved performance, TypeScript support, and developer experience

57 lines (56 loc) 1.45 kB
/** * 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. * * @param func - The function to curry * @param arity - The arity of func * @returns The new curried function * * @example * ```ts * const abc = function(a, b, c) { * return [a, b, c]; * }; * * const curried = curry(abc); * * curried(1)(2)(3); * // => [1, 2, 3] * * curried(1, 2)(3); * // => [1, 2, 3] * * curried(1, 2, 3); * // => [1, 2, 3] * ``` */ export declare function curry<T extends (...args: any[]) => any>(func: T, arity?: number): (...args: any[]) => any; /** * This method is like `curry` except that arguments are applied to func in the * manner of `partialRight` instead of `partial`. * * @param func - The function to curry * @param arity - The arity of func * @returns The new curried function * * @example * ```ts * const abc = function(a, b, c) { * return [a, b, c]; * }; * * const curried = curryRight(abc); * * curried(3)(2)(1); * // => [1, 2, 3] * * curried(2, 3)(1); * // => [1, 2, 3] * * curried(1, 2, 3); * // => [1, 2, 3] * ``` */ export declare function curryRight<T extends (...args: any[]) => any>(func: T, arity?: number): (...args: any[]) => any;