intersperse
intersperse<
T,S>(iterable,separator):IterableIterator<T|S>
Defined in: packages/core/src/iterable/intersperse.ts:14
Yields separator between consecutive elements, with none before the first
or after the last.
Array.prototype.join for values that are not strings, and lazy.
Time complexity: O(1) per element.
Type Parameters
Section titled “Type Parameters”T
S
Parameters
Section titled “Parameters”iterable
Section titled “iterable”Iterable<T>
The input iterable.
separator
Section titled “separator”S
The value to place between elements.
Returns
Section titled “Returns”IterableIterator<T | S>
An iterator over the elements, separated. Empty when the input is, and a single element is yielded alone.