Skip to content

Function: isContainer()

isContainer<T>(value): value is Container<T>

Type guard for a Container - an iterable to be treated as a collection rather than a scalar.

Deliberately excludes values that are technically iterable but should be treated as scalars here - strings, String/RegExp objects, and functions - so a lone string is never spread character-by-character.

T = unknown

Element type asserted for the iterable.

unknown

Value to test.

value is Container<T>

true (narrowing value to Container<T>) for a non-string iterable.