Skip to content

assertcheck v1.0.0


assertcheck / assert / allInstanceOf

Function: allInstanceOf()

ts
function allInstanceOf<T>(
   arr, 
   ctor, 
   opts?): asserts arr is T[];

Defined in: src/assert.ts:1361

Asserts that all elements are instances of the given constructor. Narrows the type to T[] after the call.

Type Parameters

Type Parameter
T

Parameters

ParameterType
arrunknown[]
ctor(...args) => T
opts?Opts

Returns

asserts arr is T[]

Example

ts
`assert.allInstanceOf(events, DomainEvent, "all events must be DomainEvent")`

Released under the Apache 2.0 License. Built by Vagabond Studio — senior-only for growing companies.