UNPKG

@lou.codes/iterables

Version:
21 lines (20 loc) 542 B
import type { ReadOnlyIterable, Unary } from "@lou.codes/types"; /** * Map for iterables. * * @category Generators * @example * ```typescript * const double = value => value * 2; * const mapDouble = map(double); * * mapDouble([1, 2, 3]); // [2, 4, 6] * ``` * @param mapper Mapper function. * @returns Generator function with `mapper` function set in context. */ export declare const map: <Item, MappedItem>( mapper: Unary<Item, MappedItem>, ) => ( iterable: ReadOnlyIterable<Item>, ) => Readonly<IterableIterator<MappedItem>>;