ConstElement type produced by the source iterable.
Element type emitted by the projected iterables.
Source iterable enumerated to supply values to selector.
Projection invoked with the current value and index to produce an iterable of results.
A deferred iterable yielding items from each projected iterable sequentially.
const values = [..._flatMap([1, 2], (n) => [n, n * 10])];
console.log(values); // [1, 10, 2, 20]
or using the curried version:
const values = pipeInto(
["a", "b"],
flatMap((value, index) => [`${value}${index}`, `${value.toUpperCase()}${index}`])
);
console.log([...values]); // ["a0", "A0", "b1", "B1"]
Maps each element to an iterable and yields every item from the flattened results in source order.