Skip to content

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.

T

R

Iterable<T>

The input iterable.

Callable<[T, number], R>

Receives each element and its zero-based index.

IterableIterator<R>

An iterator over the mapped values.