Skip to main content
Module

x/is_what/src/index.ts>isOneOf

JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.
Go to Latest
function isOneOf
import { isOneOf } from "https://deno.land/x/is_what@v4.1.15/src/index.ts";

A factory function that creates a function to check if the payload is one of the given types.

Examples

import { isOneOf, isNull, isUndefined } from 'is-what'

const isNullOrUndefined = isOneOf(isNull, isUndefined)

isNullOrUndefined(null) // true isNullOrUndefined(undefined) // true isNullOrUndefined(123) // false

Type Parameters

A
B extends A
C extends A

Parameters

a: TypeGuard<A, B>
b: TypeGuard<A, C>

Returns

TypeGuard<A, B | C>

A factory function that creates a function to check if the payload is one of the given types.

Examples

import { isOneOf, isNull, isUndefined } from 'is-what'

const isNullOrUndefined = isOneOf(isNull, isUndefined)

isNullOrUndefined(null) // true isNullOrUndefined(undefined) // true isNullOrUndefined(123) // false

Type Parameters

A
B extends A
C extends A
D extends A

Parameters

a: TypeGuard<A, B>
b: TypeGuard<A, C>
c: TypeGuard<A, D>

Returns

TypeGuard<A, B | C | D>

A factory function that creates a function to check if the payload is one of the given types.

Examples

import { isOneOf, isNull, isUndefined } from 'is-what'

const isNullOrUndefined = isOneOf(isNull, isUndefined)

isNullOrUndefined(null) // true isNullOrUndefined(undefined) // true isNullOrUndefined(123) // false

Type Parameters

A
B extends A
C extends A
D extends A
E extends A

Parameters

a: TypeGuard<A, B>
b: TypeGuard<A, C>
c: TypeGuard<A, D>
d: TypeGuard<A, E>

Returns

TypeGuard<A,
| B
| C
| D
| E
>

A factory function that creates a function to check if the payload is one of the given types.

Examples

import { isOneOf, isNull, isUndefined } from 'is-what'

const isNullOrUndefined = isOneOf(isNull, isUndefined)

isNullOrUndefined(null) // true isNullOrUndefined(undefined) // true isNullOrUndefined(123) // false

Type Parameters

A
B extends A
C extends A
D extends A
E extends A
F extends A

Parameters

a: TypeGuard<A, B>
b: TypeGuard<A, C>
c: TypeGuard<A, D>
d: TypeGuard<A, E>
e: TypeGuard<A, F>

Returns

TypeGuard<A,
| B
| C
| D
| E
| F
>