Skip to main content
Module

x/unknownutil/is.ts>isInstanceOf

🦕 A lightweight utility pack for handling unknown type
Go to Latest
function isInstanceOf
import { isInstanceOf } from "https://deno.land/x/unknownutil@v3.1.0/is.ts";

Return true if the type of x is instance of ctor.

import is from "./is.ts";

const a: unknown = new Date();
if (is.InstanceOf(Date)(a)) {
  // a is narrowed to Date
  const _: Date = a;
}

Type Parameters

T extends new (...args: any) => unknown

Returns

Predicate<InstanceType<T>>