es-next-tools
Version:
A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.
32 lines (31 loc) • 1.16 kB
TypeScript
export * from './array';
export * from './structures';
export * from './date';
export * from './function';
export * from './math';
export * from './object';
export * from './promise';
export * from './string';
export type AnyFunction = (...args: any[]) => any;
/**
* Composes functions from left to right.
* @param {...AnyFunction} fns - The functions to compose.
* @returns {AnyFunction} A function that runs the composed functions in sequence.
* @example
* const addOne = (x: number) => x + 1;
* const double = (x: number) => x * 2;
* const addOneThenDouble = pipe(addOne, double);
* console.log(addOneThenDouble(3)); // 8
*/
export declare const pipe: (...fns: AnyFunction[]) => AnyFunction;
/**
* Composes functions from right to left.
* @param {...AnyFunction} fns - The functions to compose.
* @returns {AnyFunction} A function that runs the composed functions in reverse sequence.
* @example
* const addOne = (x: number) => x + 1;
* const double = (x: number) => x * 2;
* const doubleAndAddOne = compose(addOne, double);
* console.log(doubleAndAddOne(3)); // 7
*/
export declare const compose: (...fns: AnyFunction[]) => AnyFunction;