Browse API packages

API · v0.12.2

is

Standard library identity checks

Member signatures use schematic object.member(...) API notation. Exported type declarations are valid TypeScript.

Type guards and predicates for common JavaScript values.

Checks use standard JavaScript and web-platform types available in current browsers, Node, Deno, and Bun. A true type-guard result narrows the input to the type shown in its signature.

ts
import is from "@rcompat/is";

is.array#

Checks whether a value is an array.

ts
is.array(x: unknown): x is unknown[];

is.arraybuffer#

Checks whether a value is an ArrayBuffer.

ts
is.arraybuffer(x: unknown): x is ArrayBuffer;

is.bigint#

Checks whether a value is a bigint.

ts
is.bigint(x: unknown): x is bigint;

is.blank#

Checks whether a value is an empty or whitespace-only string.

ts
is.blank(x: unknown): x is string;

is.blob#

Checks whether a value is a Blob.

ts
is.blob(x: unknown): x is Blob;

is.boolish#

Checks whether a value is the string "true" or "false".

ts
is.boolish(x: unknown): x is Boolish;

is.boolean#

Checks whether a value is a boolean.

ts
is.boolean(x: unknown): x is boolean;

is.branded#

Checks whether an object owns a symbol brand.

ts
is.branded<S extends symbol>(
    x: unknown,
    brand: S,
  ): x is Record<S, () => unknown>;

is.bytes#

Checks whether a value is a Uint8Array.

ts
is.bytes(x: unknown): x is Uint8Array;

is.date#

Checks whether a value is a Date.

ts
is.date(x: unknown): x is Date;

is.defined#

Checks whether a value is not undefined.

ts
is.defined<T>(x: T): x is Exclude<T, undefined>;

is.dict#

Checks whether a value is a plain object.

ts
is.dict(x: unknown): x is Dict;

is.empty#

Checks whether a string, collection, or object is empty.

ts
is.empty(x: unknown): boolean;

is.error#

Checks whether a value is an Error.

ts
is.error(x: unknown): x is Error;

is.f32#

Checks whether a number is exactly representable as a float32.

ts
is.f32(x: unknown): x is number;

is.f32array#

Checks whether a value is a Float32Array.

ts
is.f32array(x: unknown): x is Float32Array;

is.f64array#

Checks whether a value is a Float64Array.

ts
is.f64array(x: unknown): x is Float64Array;

is.falsy#

Checks whether a value is falsy.

ts
is.falsy(x: unknown): boolean;

is.file#

Checks whether a value is a File.

ts
is.file(x: unknown): x is File;

is.finite#

Checks whether a value is a finite number or bigint.

ts
is.finite(x: unknown): x is bigint | number;

is.function#

Checks whether a value is callable.

ts
is.function(x: unknown): x is UnknownFunction;

is.int#

Checks whether a value is an integer number or bigint.

ts
is.int(x: unknown): x is bigint | number;

is.iterable#

Checks whether a value implements the iterable protocol.

ts
is.iterable(x: unknown): x is Iterable<unknown>;

is.json#

Checks whether a value can be represented in JSON.

ts
is.json(x: unknown): x is JSONValue;

is.map#

Checks whether a value is a Map.

ts
is.map(x: unknown): x is Map<unknown, unknown>;

is.nan#

Checks whether a value is NaN.

ts
is.nan(x: unknown): x is number;

is.nonempty#

Checks whether a nullable value is nonempty.

ts
is.nonempty<T>(x: T | Nullish): x is T;

is.newable#

Checks whether a value is constructible with new.

ts
is.newable(x: unknown): x is Newable;

is.null#

Checks whether a value is null.

ts
is.null(x: unknown): x is null;

is.nullish#

Checks whether a value is null or undefined.

ts
is.nullish(x: unknown): x is Nullish;

is.number#

Checks whether a value is a number, including NaN.

ts
is.number(x: unknown): x is number;

is.numeric#

Checks whether a value is a decimal numeric string.

ts
is.numeric(x: unknown): x is string;

is.object#

Checks whether a value is a non-null object.

ts
is.object(x: unknown): x is object;

is.primitive#

Checks whether a value is a JavaScript primitive.

ts
is.primitive(x: unknown): x is Primitive;

is.promise#

Checks whether a value is a Promise.

ts
is.promise(x: unknown): x is Promise<unknown>;

is.request#

Checks whether a value is a Request.

ts
is.request(x: unknown): x is Request;

is.response#

Checks whether a value is a Response.

ts
is.response(x: unknown): x is Response;

is.regexp#

Checks whether a value is a regular expression.

ts
is.regexp(x: unknown): x is RegExp;

is.safeint#

Checks whether a value is a safe integer number.

ts
is.safeint(x: unknown): x is number;

is.set#

Checks whether a value is a Set.

ts
is.set(x: unknown): x is Set<unknown>;

is.stream#

Checks whether a value is a readable web stream.

ts
is.stream(x: unknown): x is ReadableStream;

is.string#

Checks whether a value is a string.

ts
is.string(x: unknown): x is string;

is.symbol#

Checks whether a value is a symbol.

ts
is.symbol(x: unknown): x is symbol;

is.text#

Checks whether a value is a nonempty, non-whitespace string.

ts
is.text(x: unknown): x is string;

is.truthy#

Checks whether a value is truthy and narrows out falsy literals.

ts
is.truthy<T>(
    x: T,
  ): x is Exclude<T, "" | 0 | 0n | false | null | undefined>;

is.typedarray#

Checks whether a value is an ArrayBuffer view.

ts
is.typedarray(x: unknown): x is ArrayBufferView;

is.uint#

Checks whether a value is a non-negative integer or bigint.

ts
is.uint(x: unknown): x is bigint | number;

is.undefined#

Checks whether a value is undefined.

ts
is.undefined(x: unknown): x is undefined;

is.url#

Checks whether a value is a URL.

ts
is.url(x: unknown): x is URL;

is.versioned#

Checks whether an object owns the requested global version brand.

Throws: If brand is not global or the object has another version of it.

ts
is.versioned(x: unknown, brand: symbol): boolean;