Skip to content

markEnds

markEnds<T>(iterable): IterableIterator<MarkedEnd<T>>

Defined in: packages/core/src/iterable/mark-ends.ts:20

Yields each element tagged with whether it is the first and whether it is the last.

What every formatter needs to decide where separators, indentation or box corners go, and the reason it is worth having: knowing an element is the last one requires a one-element lookahead, so the source always runs one step ahead of what has been yielded.

A lone element is both first and last.

Time complexity: O(1) per element, allocating one tuple per yield.

T

Iterable<T>

The input iterable.

IterableIterator<MarkedEnd<T>>

An iterator over the tagged elements.