super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
38 lines (37 loc) • 1.01 kB
TypeScript
import { AnyFunction } from '../utils/types';
/**
* Composes functions from right to left.
*
* @param funcs - The functions to compose
* @returns A function that composes the functions
*
* @example
* ```ts
* const add1 = (x: number) => x + 1;
* const multiply2 = (x: number) => x * 2;
* const subtract3 = (x: number) => x - 3;
*
* const composed = compose(subtract3, multiply2, add1);
* composed(5);
* // => ((5 + 1) * 2) - 3 = 9
* ```
*/
export declare function compose<T>(...funcs: AnyFunction[]): (arg: T) => any;
/**
* Composes functions from left to right.
*
* @param funcs - The functions to compose
* @returns A function that composes the functions
*
* @example
* ```ts
* const add1 = (x: number) => x + 1;
* const multiply2 = (x: number) => x * 2;
* const subtract3 = (x: number) => x - 3;
*
* const piped = pipe(add1, multiply2, subtract3);
* piped(5);
* // => ((5 + 1) * 2) - 3 = 9
* ```
*/
export declare function pipe<T>(...funcs: AnyFunction[]): (arg: T) => any;