UNPKG

@lumino/algorithm

Version:

Lumino Algorithms and Iterators

22 lines (21 loc) 574 B
/** * Transform the values of an iterable with a mapping function. * * @param object - The iterable object of interest. * * @param fn - The mapping function to invoke for each value. * * @returns An iterator which yields the transformed values. * * #### Example * ```typescript * import { map } from '@lumino/algorithm'; * * let data = [1, 2, 3]; * * let stream = map(data, value => value * 2); * * Array.from(stream); // [2, 4, 6] * ``` */ export declare function map<T, U>(object: Iterable<T>, fn: (value: T, index: number) => U): IterableIterator<U>;