import type { AnyFunction } from "../types.js"; /** * Creates a function that is the composition of the provided functions, * where each successive invocation is supplied the return value of the previous. * This is type-safe pipe function for better function composition. * * @param fns - The functions to invoke * @returns Returns the new composite function * * @example * const add = (x, y) => x + y; * const square = x => x * x; * const addThenSquare = pipe(add, square); * * addThenSquare(1, 2); // => 9 (square(add(1, 2))) */ export declare function pipe(ab: (...args: A) => B): (...args: A) => B; export declare function pipe(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; export declare function pipe(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; export declare function pipe(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): (...args: A) => E; export declare function pipe(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): (...args: A) => F; export declare function pipe(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): (...args: A) => G; /** * This method is like `pipe` except that it creates a function that * invokes the given functions from right to left. * * @param fns - The functions to invoke * @returns Returns the new composite function * * @example * const add = (x, y) => x + y; * const square = x => x * x; * const squareThenAdd = compose(add, square); * * squareThenAdd(1, 2); // => add(square(1), 2) => add(1, 2) => 3 */ export declare function compose(ab: (...args: A) => B): (...args: A) => B; export declare function compose(bc: (b: B) => C, ab: (...args: A) => B): (...args: A) => C; export declare function compose(cd: (c: C) => D, bc: (b: B) => C, ab: (...args: A) => B): (...args: A) => D; export declare function compose(de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...args: A) => B): (...args: A) => E; export declare function compose(ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...args: A) => B): (...args: A) => F; export declare function compose(fg: (f: F) => G, ef: (e: E) => F, de: (d: D) => E, cd: (c: C) => D, bc: (b: B) => C, ab: (...args: A) => B): (...args: A) => G; /** * Creates a function that invokes func with partials prepended to the * arguments it receives. * * @param func - The function to partially apply arguments to * @param partials - The arguments to be partially applied * @returns Returns the new partially applied function * * @example * function greet(greeting, name) { * return greeting + ' ' + name; * } * * const sayHelloTo = partial(greet, 'hello'); * sayHelloTo('fred'); * // => 'hello fred' */ export declare function partial(func: T, ...partials: any[]): (...args: any[]) => ReturnType; /** * This method is like `partial` except that partially applied arguments * are appended to the arguments it receives. * * @param func - The function to partially apply arguments to * @param partials - The arguments to be partially applied * @returns Returns the new partially applied function * * @example * function greet(greeting, name) { * return greeting + ' ' + name; * } * * const greetFred = partialRight(greet, 'fred'); * greetFred('hi'); * // => 'hi fred' */ export declare function partialRight(func: T, ...partials: any[]): (...args: any[]) => ReturnType; /** * Creates a function that invokes func with its arguments reversed. * * @param func - The function to flip arguments for * @returns Returns the new flipped function * * @example * const flipped = flip(function(a, b, c) { * return [a, b, c]; * }); * * flipped('a', 'b', 'c'); * // => ['c', 'b', 'a'] */ export declare function flip(func: T): T; /** * Creates a function that provides value to wrapper as its first * argument. Any additional arguments provided to the function are appended * to those provided to the wrapper. * * @param value - The value to wrap * @param wrapper - The wrapper function * @returns Returns the new function * * @example * const p = wrap('P', function(func, text) { * return '<' + func + '>' + text + ''; * }); * * p('Hello'); * // => '

Hello

' */ export declare function wrap(value: T, wrapper: (value: T, ...args: any[]) => any): (...args: Parameters) => ReturnType; /** * Creates a function that calls func at most n times. Subsequent calls * to the created function return the result of the last func invocation. * * @param n - The number of calls at which func is no longer invoked * @param func - The function to restrict * @returns Returns the new restricted function * * @example * jQuery(element).on('click', before(5, addContactToList)); * // => Allows adding up to 4 contacts to the list. */ export declare function before(n: number, func: T): (...args: Parameters) => ReturnType | undefined; /** * Creates a function that invokes func once it's called n or more times. * * @param n - The number of calls before func is invoked * @param func - The function to restrict * @returns Returns the new restricted function * * @example * const saves = ['profile', 'settings']; * * const done = after(saves.length, function() { * console.log('done saving!'); * }); * * forEach(saves, function(type) { * asyncSave({ 'type': type, 'complete': done }); * }); * // => Logs 'done saving!' after the two async saves have completed. */ export declare function after(n: number, func: T): (...args: Parameters) => ReturnType | undefined; /** * Creates a function that invokes func, with up to n arguments, * ignoring any additional arguments. * * @param func - The function to cap arguments for * @param n - The arity cap * @returns Returns the new capped function * * @example * map(['6', '8', '10'], ary(parseInt, 1)); * // => [6, 8, 10] */ export declare function ary(func: T, n?: number): (...args: any[]) => ReturnType; /** * Creates a function that invokes func with the this binding of thisArg * and arguments of the created function. * * @param func - The function to bind * @param thisArg - The this binding of func * @param partials - The arguments to be partially applied * @returns Returns the new bound function * * @example * function greet(greeting, punctuation) { * return greeting + ' ' + this.user + punctuation; * } * * const object = { 'user': 'fred' }; * * const bound = bind(greet, object, 'hi'); * bound('!'); * // => 'hi fred!' */ export declare function bind(func: T, thisArg: any, ...partials: any[]): (...args: any[]) => ReturnType; /** * Creates a function that invokes the method at object[key] with partials * prepended to the arguments it receives. * * @param object - The object to invoke the method on * @param key - The key of the method * @param partials - The arguments to be partially applied * @returns Returns the new bound function * * @example * const object = { * 'user': 'fred', * 'greet': function(greeting, punctuation) { * return greeting + ' ' + this.user + punctuation; * } * }; * * const bound = bindKey(object, 'greet', 'hi'); * bound('!'); * // => 'hi fred!' */ export declare function bindKey>(object: T, key: keyof T, ...partials: any[]): (...args: any[]) => ReturnType;