map
map<
T,R>(iterable,mapper):IterableIterator<R>
Defined in: packages/core/src/iterable/map.ts:19
Yields mapper(element) for each element, lazily.
The Iterable-shaped counterpart of Array.prototype.map and of
Iterator.prototype.map, neither of which accepts a plain Iterable without
first materializing it or wrapping it in Iterator.from.
Use filterMap when the mapper also needs to drop elements, and tap when the callback is a side effect rather than a transform.
Time complexity: O(1) per element, plus whatever mapper costs.
Type Parameters
Section titled “Type Parameters”T
R
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<T>
The input iterable.
mapper
Section titled “mapper”Callable<[T, number], R>
Receives each element and its zero-based index.
Returns
Section titled “Returns”IterableIterator<R>
An iterator over the mapped values.