Skip to content

instanceOfGuard()

ts
function instanceOfGuard<T>(constructor): Guard<T>

Returns a guard that checks whether the data is an instance of the given constructor.

Example

ts
const isError = instanceOfGuard(Error)
isError(new Error()) // -> true

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
constructor(...args) => Tthe right-hand side argument of the instanceof operator

Returns

Guard<T>