UNPKG

1.47 kBTypeScriptView Raw
1import '../polyfill-array';
2export declare type Mapper<A, B> = (a: A) => B;
3export declare type ArrayMapper<A, B> = (a: A, i: number, xs: A[]) => B;
4export declare type ObjectMapper<A, B> = (value: A[keyof A], key: keyof A, object: A) => B;
5export declare type SetMapper<A, B> = (a: A, xs: Set<A>) => B;
6export declare type MapValueMapper<AK, AV, BK, BV> = (v: AV, k: AK, xs: Map<AK, AV>) => BV;
7export declare type MapKeyMapper<AK, AV, BK, BV> = (v: AV, k: AK, xs: Map<AK, AV>) => BK;
8export declare type NodeListElementMapper<A extends Element, B> = (a: A, i: number, xs: NodeListOf<A> | HTMLCollectionOf<A>) => B;
9export declare namespace maps {
10 function array<A, B>(xs: A[], f: ArrayMapper<A, B>): B[];
11 function object<A, B>(x: A, f: ObjectMapper<A, B>): B;
12 function set<A, B>(xs: Set<A>, f: SetMapper<A, B>): Set<B>;
13 function map<AK, AV, BK, BV>(xs: Map<AK, AV>, valueMapper: MapValueMapper<AK, AV, BK, BV>, keyMapper?: MapKeyMapper<AK, AV, BK, BV>): Map<BK, BV>;
14 function nodeList<A extends Element, B>(xs: NodeListOf<A> | HTMLCollectionOf<A>, f: NodeListElementMapper<A, B>): any[];
15 function any(o: any, f: (a: any) => any): any;
16}
17export declare const map_array: typeof maps.array;
18export declare const map_object: typeof maps.object;
19export declare const map_set: typeof maps.set;
20export declare const map_map: typeof maps.map;
21export declare const map_nodeList: typeof maps.nodeList;
22export declare const map_any: typeof maps.any;