UNPKG

@beenotung/tslib

Version:
22 lines (21 loc) 1.38 kB
export type Mapper<A, B> = (a: A) => B; export type ArrayMapper<A, B> = (a: A, i: number, xs: A[]) => B; export type ObjectMapper<A, B> = (value: A[keyof A], key: keyof A, object: A) => B; export type SetMapper<A, B> = (a: A, xs: Set<A>) => B; export type MapValueMapper<AK, AV, BK, BV> = (v: AV, k: AK, xs: Map<AK, AV>) => BV; export type MapKeyMapper<AK, AV, BK, BV> = (v: AV, k: AK, xs: Map<AK, AV>) => BK; export type NodeListElementMapper<A extends Element, B> = (a: A, i: number, xs: NodeListOf<A> | HTMLCollectionOf<A>) => B; export declare namespace maps { function array<A, B>(xs: A[], f: ArrayMapper<A, B>): B[]; function object<A, B>(x: A, f: ObjectMapper<A, B>): B; function set<A, B>(xs: Set<A>, f: SetMapper<A, B>): Set<B>; 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>; function nodeList<A extends Element, B>(xs: NodeListOf<A> | HTMLCollectionOf<A>, f: NodeListElementMapper<A, B>): any[]; function any(o: any, f: (a: any) => any): any; } export declare const map_array: typeof maps.array; export declare const map_object: typeof maps.object; export declare const map_set: typeof maps.set; export declare const map_map: typeof maps.map; export declare const map_nodeList: typeof maps.nodeList; export declare const map_any: typeof maps.any;