Skip to content

alwaysIterable

alwaysIterable<T>(value): Iterable<T>

Defined in: packages/core/src/iterable/always-iterable.ts:19

Normalises “one item or many” into an iterable, at a boundary where a caller may pass either.

A string is treated as a single item, never as a sequence of characters — that is the whole point, and the case a bare Array.isArray check written at each call site keeps getting right by accident and a Symbol.iterator check gets wrong.

An iterable is returned as-is rather than copied, so a one-shot source stays one-shot.

Time complexity: O(1).

T

T | Iterable<T, any, any>

A single item, or an iterable of them.

Iterable<T>

value itself when it is a non-string iterable, otherwise a one-element iterable holding it.