UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

27 lines 1.23 kB
import { LazyResult } from './_reduceLazy'; import { Pred, PredIndexedOptional, PredIndexed } from './_types'; /** * Map each element of an array using a defined callback function. * @param array The array to map. * @param fn The function mapper. * @returns The new mapped array. * @signature * P.map(array, fn) * @signature * P.map(fn)(array) * @example * P.map([1, 2, 3], x => x * 2) // => [2, 4, 6] * P.pipe([0, 1, 2], P.map(x => x * 2)) // => [2, 4, 6] * @category Array, Pipe */ export declare function map<T, K>(array: readonly T[], fn: Pred<T, K>): K[]; export declare function map<T, K>(fn: Pred<T, K>): (array: readonly T[]) => K[]; export declare namespace map { function indexed<T, K>(array: readonly T[], fn: PredIndexed<T, K>): K[]; function indexed<T, K>(fn: PredIndexed<T, K>): (array: readonly T[]) => K[]; const lazy: <T, K>(fn: PredIndexedOptional<T, K>) => (value: T, index?: number | undefined, array?: readonly T[] | undefined) => LazyResult<K>; const lazyIndexed: (<T, K>(fn: PredIndexedOptional<T, K>) => (value: T, index?: number | undefined, array?: readonly T[] | undefined) => LazyResult<K>) & { indexed: true; }; } //# sourceMappingURL=map.d.ts.map