Skip to content

assertcheck v1.0.0


assertcheck / assert / one

Function: one()

ts
function one<T>(
   arr, 
   predicate, 
   opts?): void;

Defined in: src/assert.ts:947

Asserts that exactly one element satisfies the predicate — Ruby one?.

Type Parameters

Type Parameter
T

Parameters

ParameterType
arrT[]
predicate(v) => boolean
opts?Opts

Returns

void

Example

ts
`assert.one(events, e => e.type === "checkout", "exactly one checkout expected")`

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