Skip to main content
Module

x/unknownutil/is.ts>isOneOf

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

Return a type predicate function that returns true if the type of x is OneOf<T>.

import is from "./is.ts";

const preds = [is.Number, is.String, is.Boolean];
const a: unknown = 0;
if (is.OneOf(preds)(a)) {
 // a is narrowed to number | string | boolean
 const _: number | string | boolean = a;
}

Type Parameters

T extends readonly Predicate<unknown>[]