pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
26 lines (25 loc) • 2.44 kB
TypeScript
import { Mappable, Predicate } from "./types";
export declare const conjM: <A>(coll: A[], elem: A) => A[];
export declare const consM: <A>(coll: A[], elem: A) => A[];
type Transform<TColl, TNext> = (coll: TColl, next: TNext) => TColl;
type Reducer<TColl, TNext> = (coll: TColl, next: TNext) => TColl;
type Transducer<TColl, TNext> = (reducing: Reducer<TColl, TNext>) => Transform<TColl, TNext>;
type MapTransducer<TColl, TInput, TNext> = (reducing: Reducer<TColl, TNext>) => Transform<TColl, TInput>;
export declare const map: <A, B, TColl>(fn: Mappable<A, B>) => MapTransducer<TColl, A, B>;
export declare const flatMap: <A, B>(fn: Mappable<A, B | B[]>) => (reducing: Reducer<any, any>) => (coll: any, input: any) => any;
export declare const flatten: <TColl, TNext>(reducing: Reducer<TColl, TNext>) => (coll: TColl, input: TNext | TNext[]) => TColl;
export declare const filter: <TInput, TColl>(pred: Predicate<TInput>) => Transducer<TColl, TInput>;
export declare const take: <TNext, TColl>(n: number) => (reducing: Reducer<TColl, TNext>) => (coll: TColl, input: TNext) => TColl;
export declare const drop: (n: number) => <TInput, TColl>(reducing: Reducer<TColl, TInput>) => (coll: TColl, input: TInput) => TColl;
export declare const insert: <TInput>(elem: TInput) => <TColl>(reducing: Reducer<TColl, TInput>) => (coll: TColl, input: TInput) => TColl;
export declare const uniq: <TColl, TNext>(reducing: Reducer<TColl, TNext>) => (coll: TColl, input: TNext) => TColl;
export declare const uniqBy: <TNext>(toKey: (val: TNext) => any) => <TColl>(reducing: Reducer<TColl, TNext>) => (coll: TColl, input: TNext) => TColl;
export declare const find: <TInput>(pred: Predicate<TInput>) => <TColl>(reducing: Reducer<TColl, TInput>) => (coll: TColl, input: TInput) => TColl;
export declare const compact: Transducer<unknown, unknown>;
export declare const insertM: <T>(inOrder: (a: T, b: T) => boolean, arr: T[], elem: T) => T[];
export declare function transformList<A = any, B = any>(...args: [...Transducer<any, any>[], A[]]): B[];
export declare function transformList<A = any, B = any>(...args: Transducer<any, any>[]): (coll: A[]) => B[];
export declare const intoObjM: (coll: any, [k, v]: [string | symbol, any]) => any;
export declare function transformObj<A = any, B = any>(...transducers: Transducer<any, any>[]): (obj: A) => B;
export declare function transformObj<A = any, B = any>(...args: [...Transducer<any, any>[], A]): B;
export {};