@zestlet/fp
Version:
TypeScript functional programming library with over 70% AI-generated code, featuring precise type inference and currying support
705 lines (661 loc) • 191 kB
TypeScript
type ArrayContainer<T = unknown> = readonly T[];
type ArrayCallback<T, R, A = ArrayContainer<T>> = {
(item: T, index: number, array: A): R;
};
type ArrayPredicate<T, A = ArrayContainer<T>> = ArrayCallback<T, boolean, A>;
type ArrayReducer<P, C, R = P, A extends ArrayContainer = ArrayContainer<C>> = (previousValue: P, currentValue: C, index: number, array: A) => R;
declare const adjust: {
<T, U>(index: number, transform: (value: T) => U, array: ArrayContainer<T>): (T | U)[];
<T, U>(index: number, transform: (value: T) => U): <T2 extends T>(array: ArrayContainer<T2>) => (T | U)[];
<T, U>(index: number): {
<T2 extends T, U2 extends U>(transform: (value: T2) => U2, array: ArrayContainer<T2>): (T2 | U2)[];
<T2 extends T, U2_1 extends U>(transform: (value: T2) => U2_1): <T3 extends T2>(array: ArrayContainer<T3>) => (T3 | U2_1)[];
};
};
/**
* Checks if all elements in the array satisfy the given predicate function
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to check
* @returns Returns true if all elements satisfy the predicate function, false otherwise
* @example
* const array = [1, 2, 3, 4, 5];
* all(x => x > 0, array); // true
* all(x => x > 3, array); // false
* all(x => x > 0)(array); // true
*/
declare const all: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): boolean;
<T1>(predicate: ArrayPredicate<T1>): <T2 extends T1>(array: ArrayContainer<T2>) => boolean;
};
type Predicate$2<T> = (value: T) => boolean;
type BinaryFunction<A, B, R> = (a: A, b: B) => R;
type Comparator<A, B = A, R = number> = BinaryFunction<A, B, R>;
type IsNever<T> = [T] extends [never] ? true : false;
type Prettify$1<T> = {
[K in keyof T]: T[K];
} & {};
/**
* Checks if a value satisfies all the given predicate functions
*
* @category Array
* @param predicates - The array of predicate functions to test the value
* @param value - The value to check
* @returns Returns true if the value satisfies all predicates, false otherwise
* @example
* const predicates = [x => x > 0, x => x < 10];
* allPass(predicates, 5); // true
* allPass(predicates, 15); // false
* allPass(predicates)(5); // true
*/
declare const allPass: {
<T>(predicates: ArrayContainer<Predicate$2<T>>, value: T): boolean;
<T1 extends ArrayContainer<Predicate$2<any>>>(predicates: T1): <U>(value: Parameters<T1[number]>[0] & U) => boolean;
};
type GenericFunction<Args extends readonly any[] = any[], R = any> = (...args: Args) => R;
type AnyFunction = GenericFunction<any[], any>;
type Awaitable<T = any> = T | Promise<T> | PromiseLike<T>;
type AwaitableFunction<Args extends readonly any[] = any[], Return = any> = GenericFunction<Args, Awaitable<Return>>;
type FirstFn<T extends readonly AnyFunction[]> = T extends [infer First, ...any[]] ? First : never;
type ConstantFunction<T> = (...anyArgs: unknown[]) => T;
declare function alwaysImpl<T>(value: T): ConstantFunction<T>;
/**
* Returns a function that always returns the value that was passed as the argument.
* This function is useful for creating constant functions.
*
* @category Function
* @param value The value to always return
* @returns A function that always returns the value
* @example
* const alwaysTrue = always(true);
* alwaysTrue() // true
* alwaysTrue('anything') // true
*/
declare const always: typeof alwaysImpl;
/**
* Checks if any elements in the array satisfy the given predicate function
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to check
* @returns Returns true if any elements satisfy the predicate function, false otherwise
* @example
* const array = [1, 2, 3, 4, 5];
* any(x => x > 3, array); // true
* any(x => x > 5, array); // false
* any(x => x > 3)(array); // true
*/
declare const any: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): boolean;
<T1>(predicate: ArrayPredicate<T1>): <T2 extends T1>(array: ArrayContainer<T2>) => boolean;
};
/**
* Checks if a value satisfies any of the given predicate functions
*
* @category Array
* @param predicates - The array of predicate functions to test the value
* @param value - The value to check
* @returns Returns true if the value satisfies any predicate, false otherwise
* @example
* const predicates = [x => x > 0, x => x < 10];
* anyPass(predicates, 15); // true
* anyPass(predicates, -5); // false
* anyPass(predicates)(15); // true
*/
declare const anyPass: {
<T>(predicates: ArrayContainer<Predicate$2<T>>, value: T): boolean;
<T>(predicates: ArrayContainer<Predicate$2<T>>): <T2 extends T>(value: T2) => boolean;
};
/**
* Applies an array of functions to an array of values
*
* @category Array
* @param fns - Array of functions to apply
* @param values - Array of values to apply the functions to
* @returns Returns an array containing the results of applying each function to each value
* @example
* const fns = [x => x + 1, x => x * 2];
* const values = [1, 2, 3];
* ap(fns, values); // [2, 3, 4, 2, 4, 6]
*/
declare const ap: {
<T, Fn extends AnyFunction>(fns: ArrayContainer<Fn>, values: ArrayContainer<T>): ReturnType<Fn>[];
<Fn extends AnyFunction>(fns: ArrayContainer<Fn>): <T2 extends Parameters<Fn>[0]>(values: ArrayContainer<T2>) => ReturnType<Fn>[];
};
/**
* Creates a new list of n-tuples (sliding windows) from the given array
*
* @category Array
* @param size - The size of each sliding window
* @param array - The array to create sliding windows from
* @returns Returns an array of sliding windows
* @example
* const array = [1, 2, 3, 4, 5];
* aperture(3, array); // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
* aperture(2, array); // [[1, 2], [2, 3], [3, 4], [4, 5]]
* aperture(3)(array); // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
*/
declare const aperture: {
<T>(size: number, array: T): T[][];
(size: number): {
<T>(array: T): T[][];
};
};
/**
* Appends an item to the end of an array
*
* @category Array
* @param item - The item to append
* @param array - The array to append to
* @returns Returns a new array with the item appended
* @example
* const array = [1, 2, 3];
* append(4, array); // [1, 2, 3, 4]
* append('a')([1, 2, 3]); // [1, 2, 3, 'a']
*/
declare const append: {
<T, U>(item: U, array: ArrayContainer<T>): [...T[], U];
<T, U>(item: U): <T2 extends ArrayContainer<T>>(array: T2) => [...T2, U];
};
/**
* Splits an array into two arrays based on a boolean filter array
*
* @category Array
* @param filter - The boolean filter array
* @param array - The input array
* @returns Returns a tuple of two arrays, where the first array contains elements where filter is true, and the second array contains elements where filter is false
* @example
* const array = [1, 2, 3, 4];
* const filter = [true, false, true, false];
* bifurcate(filter, array); // [[1, 3], [2, 4]]
*/
declare const bifurcate: {
<T, F extends ArrayContainer<boolean>>(filter: F, array: ArrayContainer<T>): [T[], T[]];
<T, F extends ArrayContainer<boolean>>(filter: F): <T2 extends T>(array: ArrayContainer<T2>) => [T2[], T2[]];
};
/**
* Splits an array into chunks of the specified size
*
* @category Array
* @param size - The size of each chunk
* @param array - The array to split into chunks
* @returns Returns an array of chunks
* @example
* const array = [1, 2, 3, 4, 5];
* chunk(2, array); // [[1, 2], [3, 4], [5]]
* chunk(3, array); // [[1, 2, 3], [4, 5]]
* chunk(2)(array); // [[1, 2], [3, 4], [5]]
*/
declare const chunk: {
<T>(size: number, array: ArrayContainer<T>): T[][];
<T>(size: number): <T2 extends T>(array: ArrayContainer<T2>) => T2[][];
};
declare function cloneImpl<T extends Record<PropertyKey, unknown>>(obj: T): T;
/**
* Creates a shallow copy of an object
*
* @category Object
* @param obj - The object to clone
* @returns Returns a new object with the same properties as the input object
* @example
* const obj = { name: 'John', age: 30 };
* const cloned = clone(obj);
* cloned === obj; // false
* cloned.name === obj.name; // true
*/
declare const clone: typeof cloneImpl;
declare function complementImpl<T extends readonly any[], R>(fn: (...args: T) => R): (...args: T) => boolean;
/**
* Returns a function that returns the logical complement of the result of the given function.
* The given function must be a predicate function (returning a boolean value).
*
* @category Function
* @param fn The predicate function to complement
* @returns A new function that returns the logical complement of the result
* @example
* const isEven = (n: number) => n % 2 === 0;
* const isOdd = complement(isEven);
* isEven(2) // true
* isOdd(2) // false
*/
declare const complement: typeof complementImpl;
declare function compose(): <T>(x: T) => T;
declare function compose<Args extends readonly any[], R1>(f1: (...args: Args) => R1): (...args: Args) => R1;
declare function compose<Args extends readonly any[], R1, R2>(f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R2;
declare function compose<Args extends readonly any[], R1, R2, R3>(f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R3;
declare function compose<Args extends readonly any[], R1, R2, R3, R4>(f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R4;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5>(f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R5;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6>(f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R6;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7>(f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R7;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8>(f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R8;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9>(f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R9;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R10;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R11;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R12;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R13;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R14;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(f15: (x: R14) => R15, f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R15;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(f16: (x: R15) => R16, f15: (x: R14) => R15, f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R16;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(f17: (x: R16) => R17, f16: (x: R15) => R16, f15: (x: R14) => R15, f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R17;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(f18: (x: R17) => R18, f17: (x: R16) => R17, f16: (x: R15) => R16, f15: (x: R14) => R15, f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R18;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(f19: (x: R18) => R19, f18: (x: R17) => R18, f17: (x: R16) => R17, f16: (x: R15) => R16, f15: (x: R14) => R15, f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R19;
declare function compose<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(f20: (x: R19) => R20, f19: (x: R18) => R19, f18: (x: R17) => R18, f17: (x: R16) => R17, f16: (x: R15) => R16, f15: (x: R14) => R15, f14: (x: R13) => R14, f13: (x: R12) => R13, f12: (x: R11) => R12, f11: (x: R10) => R11, f10: (x: R9) => R10, f9: (x: R8) => R9, f8: (x: R7) => R8, f7: (x: R6) => R7, f6: (x: R5) => R6, f5: (x: R4) => R5, f4: (x: R3) => R4, f3: (x: R2) => R3, f2: (x: R1) => R2, f1: (...args: Args) => R1): (...args: Args) => R20;
declare function compose<Args extends readonly any[], Fns extends readonly AnyFunction[]>(...fns: Fns): (...args: Args) => ReturnType<FirstFn<Fns>>;
declare function composeAsync(): <T>(x: T) => Awaitable<T>;
declare function composeAsync<Args extends readonly any[], R1>(f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, Awaited<R1>>;
declare function composeAsync<Args extends readonly any[], R1, R2>(f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R2>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3>(f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R3>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4>(f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R4>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5>(f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R5>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6>(f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R6>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7>(f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R7>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8>(f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R8>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9>(f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R9>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R10>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R11>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R12>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R13>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R14>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(f15: AwaitableFunction<[Awaited<R14>], R15>, f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R15>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(f16: AwaitableFunction<[Awaited<R15>], R16>, f15: AwaitableFunction<[Awaited<R14>], R15>, f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R16>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(f17: AwaitableFunction<[Awaited<R16>], R17>, f16: AwaitableFunction<[Awaited<R15>], R16>, f15: AwaitableFunction<[Awaited<R14>], R15>, f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R17>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(f18: AwaitableFunction<[Awaited<R17>], R18>, f17: AwaitableFunction<[Awaited<R16>], R17>, f16: AwaitableFunction<[Awaited<R15>], R16>, f15: AwaitableFunction<[Awaited<R14>], R15>, f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R18>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(f19: AwaitableFunction<[Awaited<R18>], R19>, f18: AwaitableFunction<[Awaited<R17>], R18>, f17: AwaitableFunction<[Awaited<R16>], R17>, f16: AwaitableFunction<[Awaited<R15>], R16>, f15: AwaitableFunction<[Awaited<R14>], R15>, f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R19>;
declare function composeAsync<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(f20: AwaitableFunction<[Awaited<R19>], R20>, f19: AwaitableFunction<[Awaited<R18>], R19>, f18: AwaitableFunction<[Awaited<R17>], R18>, f17: AwaitableFunction<[Awaited<R16>], R17>, f16: AwaitableFunction<[Awaited<R15>], R16>, f15: AwaitableFunction<[Awaited<R14>], R15>, f14: AwaitableFunction<[Awaited<R13>], R14>, f13: AwaitableFunction<[Awaited<R12>], R13>, f12: AwaitableFunction<[Awaited<R11>], R12>, f11: AwaitableFunction<[Awaited<R10>], R11>, f10: AwaitableFunction<[Awaited<R9>], R10>, f9: AwaitableFunction<[Awaited<R8>], R9>, f8: AwaitableFunction<[Awaited<R7>], R8>, f7: AwaitableFunction<[Awaited<R6>], R7>, f6: AwaitableFunction<[Awaited<R5>], R6>, f5: AwaitableFunction<[Awaited<R4>], R5>, f4: AwaitableFunction<[Awaited<R3>], R4>, f3: AwaitableFunction<[Awaited<R2>], R3>, f2: AwaitableFunction<[Awaited<R1>], R2>, f1: AwaitableFunction<Args, R1>): AwaitableFunction<Args, R20>;
declare function composeAsync<Args extends readonly any[], Fns extends readonly AwaitableFunction[]>(...fns: Fns): AwaitableFunction<Args, ReturnType<FirstFn<Fns>>>;
/**
* Concatenates two arrays
*
* @category Array
* @param arrayB - The second array to concatenate
* @param arrayA - The first array to concatenate
* @returns Returns a new array containing elements from both arrays
* @example
* const array1 = [1, 2, 3];
* const array2 = [4, 5, 6];
* concat(array2, array1); // [1, 2, 3, 4, 5, 6]
* concat(array2)(array1); // [1, 2, 3, 4, 5, 6]
*/
declare const concat: {
<T, U>(arrayB: ArrayContainer<U>, arrayA: ArrayContainer<T>): (T | U)[];
<U>(arrayB: ArrayContainer<U>): <T>(arrayA: ArrayContainer<T>) => (T | U)[];
};
/**
* Counts the occurrences of elements in an array based on a key function
*
* @category Array
* @param callbackFn - The function to generate keys for counting
* @param array - The array to count elements from
* @returns Returns an object with keys from callbackFn and their counts as values
* @example
* const array = [1, 2, 3, 4, 5];
* countBy(x => x % 2 === 0 ? 'even' : 'odd', array); // { odd: 3, even: 2 }
* countBy(x => x % 2 === 0 ? 'even' : 'odd')(array); // { odd: 3, even: 2 }
*/
declare const countBy: {
<T, K extends PropertyKey>(callbackFn: ArrayCallback<T, K>, array: ArrayContainer<T>): Record<K, number>;
<T, K extends PropertyKey>(callbackFn: ArrayCallback<T, K>): <T2 extends T>(array: ArrayContainer<T2>) => Record<K, number>;
};
declare function curry<T extends any[], R>(fn: (...args: T) => R): (...args: any[]) => any;
/**
* Returns an array containing elements that exist in the first array but not in the second array
*
* @category Array
* @param array1 - The first array to compare
* @param array2 - The second array to compare against
* @returns Returns a new array containing elements unique to the first array
* @example
* const array1 = [1, 2, 3, 4, 5];
* const array2 = [2, 4, 6];
* difference(array1, array2); // [1, 3, 5]
* difference(array1)(array2); // [1, 3, 5]
*/
declare const difference: {
<T, U>(arrayB: ArrayContainer<U>, arrayA: ArrayContainer<T>): T[];
<U>(arrayB: ArrayContainer<U>): <T>(arrayA: ArrayContainer<T>) => T[];
};
/**
* Creates an array of values from the first array that are not present in the second array,
* using an iteratee function to determine equality
*
* @category Array
* @param iteratee - The function invoked per element
* @param array1 - The array to inspect
* @param array2 - The array of values to exclude
* @returns Returns the new array of filtered values
* @example
* const array1 = [{ x: 1 }, { x: 2 }];
* const array2 = [{ x: 1 }];
* differenceBy(item => item.x, array1, array2); // => [{ x: 2 }]
*/
declare const differenceBy: {
<T, U, I>(iteratee: ArrayCallback<T | U, I>, array2: ArrayContainer<U>, array1: ArrayContainer<T>): T[];
<T, U, I>(iteratee: ArrayCallback<T | U, I>): <T2 extends T, U2 extends U>(array2: ArrayContainer<U2>, array1: ArrayContainer<T2>) => T2[];
<T, U, I>(iteratee: ArrayCallback<T | U, I>): <T2 extends T, U2 extends U>(array2: ArrayContainer<U2>) => <T3 extends T2>(array1: ArrayContainer<T3>) => T3[];
};
/**
* Creates an array of values from the first array that are not present in the second array,
* using a custom comparator function to determine equality
*
* @category Array
* @param comparator - The function used to compare elements
* @param array1 - The array to inspect
* @param array2 - The array of values to exclude
* @returns Returns the new array of filtered values
* @example
* const array1 = [{ x: 1, y: 2 }, { x: 2, y: 1 }];
* const array2 = [{ x: 1, y: 2 }];
* differenceWith((a, b) => a.x === b.x && a.y === b.y, array1, array2); // => [{ x: 2, y: 1 }]
*/
declare const differenceWith: {
<T, U>(comparator: Comparator<T, U, boolean>, array2: ArrayContainer<U>, array1: ArrayContainer<T>): T[];
<T, U>(comparator: Comparator<T, U, boolean>, array2: ArrayContainer<U>): <T2 extends T>(array1: ArrayContainer<T2>) => T2[];
<T, U>(comparator: Comparator<T, U, boolean>): {
<U2 extends U, T2 extends T>(array2: ArrayContainer<U2>, array1: ArrayContainer<T2>): T2[];
<U2 extends U>(array2: ArrayContainer<U2>): <T2_1 extends T>(array1: ArrayContainer<T2_1>) => T2_1[];
};
};
/**
* Drops the first n elements from an array
*
* @category Array
* @param count - The number of elements to drop from the beginning
* @param array - The input array
* @returns A new array with the first n elements dropped
* @example
* const array = [1, 2, 3, 4, 5];
* drop(2, array); // [3, 4, 5]
* drop(0, array); // [1, 2, 3, 4, 5]
* drop(2)(array); // [3, 4, 5]
*/
declare const drop: {
<T>(count: number, array: ArrayContainer<T>): T[];
(count: number): <T>(array: ArrayContainer<T>) => T[];
};
/**
* Drops the specified number of elements from the end of an array
*
* @category Array
* @param count - The number of elements to drop from the end
* @param array - The input array
* @returns A new array with the specified number of elements dropped from the end
* @example
* const array = [1, 2, 3, 4, 5];
* dropLast(2, array); // [1, 2, 3]
* dropLast(0, array); // [1, 2, 3, 4, 5]
* dropLast(2)(array); // [1, 2, 3]
*/
declare const dropLast: {
<T>(count: number, array: ArrayContainer<T>): T[];
(count: number): <T>(array: ArrayContainer<T>) => T[];
};
/**
* Drops elements from the end of an array while the predicate function returns true
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to process
* @returns Returns a new array with elements dropped from the end while predicate returns true
* @example
* const array = [1, 2, 3, 4, 5];
* dropLastWhile(x => x > 3, array); // [1, 2, 3]
* dropLastWhile(x => x > 0, array); // []
* dropLastWhile(x => x > 3)(array); // [1, 2, 3]
*/
declare const dropLastWhile: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): T[];
<T>(predicate: ArrayPredicate<T>): <T2 extends T>(array: ArrayContainer<T2>) => T2[];
};
declare function dropRepeatsImpl<T>(array: ArrayContainer<T>): T[];
/**
* Removes consecutive duplicate elements from an array
*
* @category Array
* @param array - The array to remove consecutive duplicates from
* @returns Returns a new array with consecutive duplicates removed
* @example
* const array = [1, 1, 2, 2, 3, 3, 3, 4];
* dropRepeats(array); // [1, 2, 3, 4]
*/
declare const dropRepeats: typeof dropRepeatsImpl;
/**
* Removes consecutive duplicate elements from an array using a custom comparison function
*
* @category Array
* @param comparator - The function to compare consecutive elements
* @param array - The array to remove consecutive duplicates from
* @returns Returns a new array with consecutive duplicates removed
* @example
* const array = [{ id: 1 }, { id: 1 }, { id: 2 }, { id: 2 }];
* dropRepeatsWith((a, b) => a.id === b.id, array); // [{ id: 1 }, { id: 2 }]
*/
declare const dropRepeatsWith: {
<T>(comparator: Comparator<T, T, boolean>, array: ArrayContainer<T>): T[];
<T>(comparator: Comparator<T, T, boolean>): <T2 extends T>(array: ArrayContainer<T2>) => T2[];
};
/**
* Drops elements from the beginning of an array while the predicate function returns true
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to process
* @returns Returns a new array with elements dropped from the beginning while predicate returns true
* @example
* const array = [1, 2, 3, 4, 5];
* dropWhile(x => x < 3, array); // [3, 4, 5]
* dropWhile(x => x > 0, array); // []
* dropWhile(x => x < 3)(array); // [3, 4, 5]
*/
declare const dropWhile: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): T[];
<T>(predicate: ArrayPredicate<T>): <T2 extends T>(array: ArrayContainer<T2>) => T2[];
};
/**
* Returns false.
* This function is useful as a default or placeholder function.
*
* @category Function
* @returns false
* @example
* False() // false
*/
declare function False(..._: unknown[]): false;
/**
* Filters elements in an array based on a predicate function
*
* @category Array
* @param predicate - The function to test each element
* @param array - The array to filter
* @returns Returns a new array with elements that pass the test implemented by the predicate
* @example
* const array = [1, 2, 3, 4, 5];
* filter(x => x % 2 === 0, array); // [2, 4]
* filter(x => x > 3)(array); // [4, 5]
*/
declare const filter: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): T[];
<Fn extends ArrayPredicate<any>>(predicate: Fn): <T2 extends Parameters<Fn>[0]>(array: ArrayContainer<T2>) => T2[];
};
declare function flow(): <T>(x: T) => T;
declare function flow<A extends AnyFunction>(a: A): A;
declare function flow<Args extends readonly any[], R1, R2>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2): (...arg: Args) => R2;
declare function flow<Args extends readonly any[], R1, R2, R3>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3): (...arg: Args) => R3;
declare function flow<Args extends readonly any[], R1, R2, R3, R4>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4): (...arg: Args) => R4;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5): (...arg: Args) => R5;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6): (...arg: Args) => R6;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7): (...arg: Args) => R7;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8): (...arg: Args) => R8;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9): (...arg: Args) => R9;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10): (...arg: Args) => R10;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11): (...arg: Args) => R11;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12): (...arg: Args) => R12;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13): (...arg: Args) => R13;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14): (...arg: Args) => R14;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14, f15: (arg: R14) => R15): (...arg: Args) => R15;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14, f15: (arg: R14) => R15, f16: (arg: R15) => R16): (...arg: Args) => R16;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14, f15: (arg: R14) => R15, f16: (arg: R15) => R16, f17: (arg: R16) => R17): (...arg: Args) => R17;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14, f15: (arg: R14) => R15, f16: (arg: R15) => R16, f17: (arg: R16) => R17, f18: (arg: R17) => R18): (...arg: Args) => R18;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14, f15: (arg: R14) => R15, f16: (arg: R15) => R16, f17: (arg: R16) => R17, f18: (arg: R17) => R18, f19: (arg: R18) => R19): (...arg: Args) => R19;
declare function flow<Args extends readonly any[], R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, R20>(f1: (...arg: Args) => R1, f2: (arg: R1) => R2, f3: (arg: R2) => R3, f4: (arg: R3) => R4, f5: (arg: R4) => R5, f6: (arg: R5) => R6, f7: (arg: R6) => R7, f8: (arg: R7) => R8, f9: (arg: R8) => R9, f10: (arg: R9) => R10, f11: (arg: R10) => R11, f12: (arg: R11) => R12, f13: (arg: R12) => R13, f14: (arg: R13) => R14, f15: (arg: R14) => R15, f16: (arg: R15) => R16, f17: (arg: R16) => R17, f18: (arg: R17) => R18, f19: (arg: R18) => R19, f20: (arg: R19) => R20): (...arg: Args) => R20;
/**
* Returns the first element in the array that satisfies the predicate function
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to search
* @returns Returns the first element that passes the predicate check, or undefined if no element passes
* @example
* const array = [1, 2, 3, 4, 5];
* find(x => x > 3, array); // 4
* find(x => x > 10, array); // undefined
* find(x => x > 3)(array); // 4
*/
declare const find: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): T | undefined;
<T = any>(predicate: ArrayPredicate<T>): <T2 extends T>(array: ArrayContainer<T2>) => T2 | undefined;
};
/**
* Returns the index of the first element in the array that satisfies the predicate function
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to search
* @returns Returns the index of the first element that passes the predicate check, or -1 if no element passes
* @example
* const array = [1, 2, 3, 4, 5];
* findIndex(x => x > 3, array); // 3
* findIndex(x => x < 0, array); // -1
* findIndex(x => x > 3)(array); // 3
*/
declare const findIndex: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): number;
<T = any>(predicate: ArrayPredicate<T>): <T2 extends T>(array: ArrayContainer<T2>) => number;
};
/**
* Returns the last element in the array that satisfies the predicate function
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to search
* @returns Returns the last element that passes the predicate check, or undefined if no element passes
* @example
* const array = [1, 2, 3, 4, 5];
* findLast(x => x > 3, array); // 5
* findLast(x => x > 10, array); // undefined
* findLast(x => x > 3)(array); // 5
*/
declare const findLast: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): T | undefined;
<T>(predicate: ArrayPredicate<T>): <T2 extends T>(array: ArrayContainer<T2>) => T2 | undefined;
};
/**
* Returns the index of the last element in the array that satisfies the predicate function
*
* @category Array
* @param predicate - The predicate function to test each element
* @param array - The array to search
* @returns Returns the index of the last element that passes the predicate check, or -1 if no element passes
* @example
* const array = [1, 2, 3, 4, 5, 3];
* findLastIndex(x => x === 3, array); // 5
* findLastIndex(x => x < 0, array); // -1
* findLastIndex(x => x === 3)(array); // 5
*/
declare const findLastIndex: {
<T>(predicate: ArrayPredicate<T>, array: ArrayContainer<T>): number;
<T>(predicate: ArrayPredicate<T>): <T2 extends T>(array: ArrayContainer<T2>) => number;
};
declare function firstImpl<T>(array: ArrayContainer<T>): T | undefined;
/**
* Returns the first element of an array
*
* @category Array
* @param array - The array to get the first element from
* @returns Returns the first element of the array, or undefined if the array is empty
* @example
* const array = [1, 2, 3, 4, 5];
* first(array); // 1
* first([]); // undefined
* first()(array); // 1
*/
declare const first: typeof firstImpl;
type ArrayFlatten<T, Depth extends number = 1> = Depth extends 0 ? T : ArrayFlatten<FlattenArray<T>, [-1, 0, 1, 2, 3, 4, 5][Depth]>;
type FlattenArrayInner<T> = T extends readonly (infer Item)[] ? (Item extends readonly any[] ? Item[number][] : Item[]) : T[];
type FlattenArray<T> = FlattenArrayInner<T>[number][];
declare const flatMap: {
<T, R>(callbackfn: ArrayCallback<T, R>, data: ArrayContainer<T>): FlattenArray<R>;
<T, R>(callbackfn: ArrayCallback<T, R>): (array: ArrayContainer<T>) => FlattenArray<R>;
};
/**
* Flattens an array up to the specified depth
*
* @category Array
* @param n - The depth level specifying how deep a nested array structure should be flattened
* @param array - The array to flatten
* @returns Returns the new flattened array
* @example
* const array = [1, [2, [3, [4]], 5]];
* flatten(1, array); // [1, 2, [3, [4]], 5]
* flatten(2, array); // [1, 2, 3, [4], 5]
* flatten(1)(array); // [1, 2, [3, [4]], 5]
*/
declare const flatten: {
<T, const Depth extends number>(n: Depth, array: ArrayContainer<T>): ArrayFlatten<T, Depth>;
<T, const Depth extends number>(n: Depth): (array: ArrayContainer<T>) => ArrayFlatten<T, Depth>;
};
/**
* Returns a new function that takes the first two arguments in reverse order.
* Any additional arguments will be passed in their original order.
*
* @category Function
* @param fn The function to flip
* @returns A new function with the first two arguments flipped
* @example
* const subtract = (a: number, b: number) => a - b;
* const flippedSubtract = flip(subtract);
* subtract(5, 3) // 2
* flippedSubtract(5, 3) // -2
*/
declare function flipImpl<T, U, R>(fn: (a: T, b: U, ...args: any[]) => R): (b: U, a: T, ...args: any[]) => R;
declare const flip: typeof flipImpl;
/**
* Executes a function for each element in the array and returns the original array
*
* @category Array
* @param callbackFn - The function to execute for each element
* @param array - The array to iterate over
* @returns Returns the original array
* @example
* const array = [1, 2, 3];
* forEach(x => console.log(x), array); // logs: 1, 2, 3
* // => [1, 2, 3]
*/
declare const forEach: {
<T>(callbackFn: ArrayCallback<T, unknown>, array: ArrayContainer<T>): ArrayContainer<T>;
<T>(callbackFn: ArrayCallback<T, unknown>): (array: ArrayContainer<T>) => ArrayContainer<T>;
};
type StrictPairs = readonly (readonly [PropertyKey, any])[];
type LoosePairs = unknown[][];
type FromPairsStrict<T extends StrictPairs> = {
[P in T[number] as P[0]]: P[1];
};
type FromPairsLoose<T extends LoosePairs> = Record<Extract<T[number][number], PropertyKey>, T[number][number]>;
type FromPairs<T extends StrictPairs | LoosePairs> = Prettify$1<T extends StrictPairs ? FromPairsStrict<T> : T extends LoosePairs ? FromPairsLoose<T> : never>;
declare function fromPairsImpl<T extends StrictPairs | LoosePairs>(pairs: T): FromPairs<T>;
/**
* Creates an object from an array of key-value pairs
*
* @category Array
* @param pairs - The array of key-value pairs
* @returns Returns an object created from the key-value pairs
* @example
* const pairs = [['a', 1], ['b', 2], ['c', 3]];
* fromPairs(pairs); // { a: 1, b: 2, c: 3 }
*/
declare const fromPairs: typeof fromPairsImpl;
/**
* Groups the elements of an array based on the result of a key function
*
* @category Array
* @param callbackFn - The