import { isInstanceOf } from "https://deno.land/x/unknownutil@v3.18.1/is.ts";
Return true
if the type of x
is instance of ctor
.
To enhance performance, users are advised to cache the return value of this function and mitigate the creation cost.
import { is } from "@core/unknownutil";
const isMyType = is.InstanceOf(Date);
const a: unknown = new Date();
if (isMyType(a)) {
// a is narrowed to Date
const _: Date = a;
}
Parameters
ctor: T
Returns
Predicate<InstanceType<T>> & WithMetadata<IsInstanceOfMetadata>