Skip to content

assertElements<T>(values, isElement, makeError): asserts values is readonly T[]

Defined in: packages/errors/src/index.ts:144

Assert that every element of values satisfies isElement, narrowing its type. Throws the error makeError builds for the first element that fails, naming its index.

Factored out because more than one package builds this same find-the-first-invalid-element check around its own ParseError subclass when decoding a serialized payload’s element array.

T

readonly unknown[]

(value) => value is T

(invalidIndex) => KnotkitError

asserts values is readonly T[]