• Version 4.2.1
  • Published
  • 55.3 kB
  • No dependencies
  • MIT license


npm i @sindresorhus/is
yarn add @sindresorhus/is
pnpm add @sindresorhus/is


Type check values






Type Aliases



variable assert

const assert: Assert;

    variable objectTypeNames

    const objectTypeNames: readonly [
    | 'Int8Array'
    | 'Uint8Array'
    | 'Uint8ClampedArray'
    | 'Int16Array'
    | 'Uint16Array'
    | 'Int32Array'
    | 'Uint32Array'
    | 'Float32Array'
    | 'Float64Array'
    | 'BigInt64Array'
    | 'BigUint64Array'

      variable primitiveTypeNames

      const primitiveTypeNames: readonly [


        function is

        is: typeof is;


          interface ArrayLike

          interface ArrayLike<T> {}

            property length

            readonly length: number;

              index signature

              readonly [index: number]: T;

                interface NodeStream

                interface NodeStream extends NodeJS.EventEmitter {}

                  method pipe

                  pipe: <T extends any>(destination: T, options?: { end?: boolean }) => T;

                    interface ObservableLike

                    interface ObservableLike {}
                    • Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable).

                    method [Symbol.observable]

                    [Symbol.observable]: () => ObservableLike;

                      method subscribe

                      subscribe: (observer: (value: unknown) => void) => void;


                        enum AssertionTypeDescription

                        const enum AssertionTypeDescription {
                        class_ = 'Class',
                        numericString = 'string with a number',
                        nullOrUndefined = 'null or undefined',
                        iterable = 'Iterable',
                        asyncIterable = 'AsyncIterable',
                        nativePromise = 'native Promise',
                        urlString = 'string with a URL',
                        truthy = 'truthy',
                        falsy = 'falsy',
                        nan = 'NaN',
                        primitive = 'primitive',
                        integer = 'integer',
                        safeInteger = 'integer',
                        plainObject = 'plain object',
                        arrayLike = 'array-like',
                        typedArray = 'TypedArray',
                        domElement = 'HTMLElement',
                        nodeStream = 'Node.js Stream',
                        infinite = 'infinite number',
                        emptyArray = 'empty array',
                        nonEmptyArray = 'non-empty array',
                        emptyString = 'empty string',
                        nonEmptyString = 'non-empty string',
                        emptyStringOrWhitespace = 'empty string or whitespace',
                        emptyObject = 'empty object',
                        nonEmptyObject = 'non-empty object',
                        emptySet = 'empty set',
                        nonEmptySet = 'non-empty set',
                        emptyMap = 'empty map',
                        nonEmptyMap = 'non-empty map',
                        evenInteger = 'even integer',
                        oddInteger = 'odd integer',
                        directInstanceOf = 'T',
                        inRange = 'in range',
                        any = 'predicate returns truthy for any value',
                        all = 'predicate returns truthy for all values',

                          member all

                          all = 'predicate returns truthy for all values'

                            member any

                            any = 'predicate returns truthy for any value'

                              member arrayLike

                              arrayLike = 'array-like'

                                member asyncIterable

                                asyncIterable = 'AsyncIterable'

                                  member class_

                                  class_ = 'Class'

                                    member directInstanceOf

                                    directInstanceOf = 'T'

                                      member domElement

                                      domElement = 'HTMLElement'

                                        member emptyArray

                                        emptyArray = 'empty array'

                                          member emptyMap

                                          emptyMap = 'empty map'

                                            member emptyObject

                                            emptyObject = 'empty object'

                                              member emptySet

                                              emptySet = 'empty set'

                                                member emptyString

                                                emptyString = 'empty string'

                                                  member emptyStringOrWhitespace

                                                  emptyStringOrWhitespace = 'empty string or whitespace'

                                                    member evenInteger

                                                    evenInteger = 'even integer'

                                                      member falsy

                                                      falsy = 'falsy'

                                                        member infinite

                                                        infinite = 'infinite number'

                                                          member inRange

                                                          inRange = 'in range'

                                                            member integer

                                                            integer = 'integer'

                                                              member iterable

                                                              iterable = 'Iterable'

                                                                member nan

                                                                nan = 'NaN'

                                                                  member nativePromise

                                                                  nativePromise = 'native Promise'

                                                                    member nodeStream

                                                                    nodeStream = 'Node.js Stream'

                                                                      member nonEmptyArray

                                                                      nonEmptyArray = 'non-empty array'

                                                                        member nonEmptyMap

                                                                        nonEmptyMap = 'non-empty map'

                                                                          member nonEmptyObject

                                                                          nonEmptyObject = 'non-empty object'

                                                                            member nonEmptySet

                                                                            nonEmptySet = 'non-empty set'

                                                                              member nonEmptyString

                                                                              nonEmptyString = 'non-empty string'

                                                                                member nullOrUndefined

                                                                                nullOrUndefined = 'null or undefined'

                                                                                  member numericString

                                                                                  numericString = 'string with a number'

                                                                                    member oddInteger

                                                                                    oddInteger = 'odd integer'

                                                                                      member plainObject

                                                                                      plainObject = 'plain object'

                                                                                        member primitive

                                                                                        primitive = 'primitive'

                                                                                          member safeInteger

                                                                                          safeInteger = 'integer'

                                                                                            member truthy

                                                                                            truthy = 'truthy'

                                                                                              member typedArray

                                                                                              typedArray = 'TypedArray'

                                                                                                member urlString

                                                                                                urlString = 'string with a URL'

                                                                                                  Type Aliases

                                                                                                  type Class

                                                                                                  type Class<T = unknown, Arguments extends any[] = any[]> = new (
                                                                                                  ...arguments_: Arguments
                                                                                                  ) => T;
                                                                                                  • Matches a [class constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).

                                                                                                  type Predicate

                                                                                                  type Predicate = (value: unknown) => boolean;

                                                                                                    type Primitive

                                                                                                    type Primitive = null | undefined | string | number | boolean | symbol | bigint;
                                                                                                    • Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).

                                                                                                    type TypedArray

                                                                                                    type TypedArray =
                                                                                                    | Int8Array
                                                                                                    | Uint8Array
                                                                                                    | Uint8ClampedArray
                                                                                                    | Int16Array
                                                                                                    | Uint16Array
                                                                                                    | Int32Array
                                                                                                    | Uint32Array
                                                                                                    | Float32Array
                                                                                                    | Float64Array
                                                                                                    | BigInt64Array
                                                                                                    | BigUint64Array;
                                                                                                    • Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like Uint8Array or Float64Array.

                                                                                                    type TypeName

                                                                                                    type TypeName = ObjectTypeName | PrimitiveTypeName;


                                                                                                      namespace is

                                                                                                      namespace is {}

                                                                                                        function all

                                                                                                        all: (predicate: Predicate, ...values: unknown[]) => boolean;

                                                                                                          function any

                                                                                                          any: (predicate: Predicate | Predicate[], ...values: unknown[]) => boolean;

                                                                                                            function array

                                                                                                            array: <T = unknown>(
                                                                                                            value: unknown,
                                                                                                            assertion?: (value: T) => value is T
                                                                                                            ) => value is T[];

                                                                                                              function arrayBuffer

                                                                                                              arrayBuffer: (value: unknown) => value is ArrayBuffer;

                                                                                                                function arrayLike

                                                                                                                arrayLike: <T = unknown>(value: unknown) => value is ArrayLike<T>;

                                                                                                                  function asyncFunction

                                                                                                                  asyncFunction: <T = unknown>(
                                                                                                                  value: unknown
                                                                                                                  ) => value is (...args: any[]) => Promise<T>;

                                                                                                                    function asyncGenerator

                                                                                                                    asyncGenerator: (
                                                                                                                    value: unknown
                                                                                                                    ) => value is AsyncGenerator<unknown, any, unknown>;

                                                                                                                      function asyncGeneratorFunction

                                                                                                                      asyncGeneratorFunction: (
                                                                                                                      value: unknown
                                                                                                                      ) => value is (...args: any[]) => Promise<unknown>;

                                                                                                                        function asyncIterable

                                                                                                                        asyncIterable: <T = unknown>(value: unknown) => value is AsyncIterable<T>;

                                                                                                                          function bigint

                                                                                                                          bigint: (value: unknown) => value is bigint;

                                                                                                                            function bigInt64Array

                                                                                                                            bigInt64Array: (value: unknown) => value is BigInt64Array;

                                                                                                                              function bigUint64Array

                                                                                                                              bigUint64Array: (value: unknown) => value is BigUint64Array;

                                                                                                                                function boolean

                                                                                                                                boolean: (value: unknown) => value is boolean;

                                                                                                                                  function boundFunction

                                                                                                                                  boundFunction: (value: unknown) => value is Function;

                                                                                                                                    function buffer

                                                                                                                                    buffer: (value: unknown) => value is any;

                                                                                                                                      function class_

                                                                                                                                      class_: (value: unknown) => value is Class<unknown, any[]>;

                                                                                                                                        function dataView

                                                                                                                                        dataView: (value: unknown) => value is DataView;

                                                                                                                                          function date

                                                                                                                                          date: (value: unknown) => value is Date;

                                                                                                                                            function directInstanceOf

                                                                                                                                            directInstanceOf: <T>(
                                                                                                                                            instance: unknown,
                                                                                                                                            class_: Class<T, any[]>
                                                                                                                                            ) => instance is T;

                                                                                                                                              function domElement

                                                                                                                                              domElement: (value: unknown) => value is HTMLElement;

                                                                                                                                                function emptyArray

                                                                                                                                                emptyArray: (value: unknown) => value is never[];

                                                                                                                                                  function emptyMap

                                                                                                                                                  emptyMap: (value: unknown) => value is Map<never, never>;

                                                                                                                                                    function emptyObject

                                                                                                                                                    emptyObject: <Key extends string | number | symbol = string>(
                                                                                                                                                    value: unknown
                                                                                                                                                    ) => value is Record<Key, never>;

                                                                                                                                                      function emptySet

                                                                                                                                                      emptySet: (value: unknown) => value is Set<never>;

                                                                                                                                                        function emptyString

                                                                                                                                                        emptyString: (value: unknown) => value is '';

                                                                                                                                                          function emptyStringOrWhitespace

                                                                                                                                                          emptyStringOrWhitespace: (value: unknown) => value is string;

                                                                                                                                                            function error

                                                                                                                                                            error: (value: unknown) => value is Error;

                                                                                                                                                              function evenInteger

                                                                                                                                                              evenInteger: (value: number) => value is number;

                                                                                                                                                                function falsy

                                                                                                                                                                falsy: (value: unknown) => boolean;

                                                                                                                                                                  function float32Array

                                                                                                                                                                  float32Array: (value: unknown) => value is Float32Array;

                                                                                                                                                                    function float64Array

                                                                                                                                                                    float64Array: (value: unknown) => value is Float64Array;

                                                                                                                                                                      function formData

                                                                                                                                                                      formData: (value: unknown) => value is FormData;

                                                                                                                                                                        function function_

                                                                                                                                                                        function_: (value: unknown) => value is Function;

                                                                                                                                                                          function generator

                                                                                                                                                                          generator: (value: unknown) => value is Generator<unknown, any, unknown>;

                                                                                                                                                                            function generatorFunction

                                                                                                                                                                            generatorFunction: (value: unknown) => value is GeneratorFunction;

                                                                                                                                                                              function infinite

                                                                                                                                                                              infinite: (value: unknown) => value is number;

                                                                                                                                                                                function inRange

                                                                                                                                                                                inRange: (value: number, range: number | number[]) => value is number;

                                                                                                                                                                                  function int16Array

                                                                                                                                                                                  int16Array: (value: unknown) => value is Int16Array;

                                                                                                                                                                                    function int32Array

                                                                                                                                                                                    int32Array: (value: unknown) => value is Int32Array;

                                                                                                                                                                                      function int8Array

                                                                                                                                                                                      int8Array: (value: unknown) => value is Int8Array;

                                                                                                                                                                                        function integer

                                                                                                                                                                                        integer: (value: unknown) => value is number;

                                                                                                                                                                                          function iterable

                                                                                                                                                                                          iterable: <T = unknown>(value: unknown) => value is Iterable<T>;

                                                                                                                                                                                            function map

                                                                                                                                                                                            map: <Key = unknown, Value = unknown>(
                                                                                                                                                                                            value: unknown
                                                                                                                                                                                            ) => value is Map<Key, Value>;

                                                                                                                                                                                              function nan

                                                                                                                                                                                              nan: (value: unknown) => boolean;

                                                                                                                                                                                                function nativePromise

                                                                                                                                                                                                nativePromise: <T = unknown>(value: unknown) => value is Promise<T>;

                                                                                                                                                                                                  function nodeStream

                                                                                                                                                                                                  nodeStream: (value: unknown) => value is NodeStream;

                                                                                                                                                                                                    function nonEmptyArray

                                                                                                                                                                                                    nonEmptyArray: (value: unknown) => value is unknown[];

                                                                                                                                                                                                      function nonEmptyMap

                                                                                                                                                                                                      nonEmptyMap: <Key = unknown, Value = unknown>(
                                                                                                                                                                                                      value: unknown
                                                                                                                                                                                                      ) => value is Map<Key, Value>;

                                                                                                                                                                                                        function nonEmptyObject

                                                                                                                                                                                                        nonEmptyObject: <Key extends string | number | symbol = string, Value = unknown>(
                                                                                                                                                                                                        value: unknown
                                                                                                                                                                                                        ) => value is Record<Key, Value>;

                                                                                                                                                                                                          function nonEmptySet

                                                                                                                                                                                                          nonEmptySet: <T = unknown>(value: unknown) => value is Set<T>;

                                                                                                                                                                                                            function nonEmptyString

                                                                                                                                                                                                            nonEmptyString: (value: unknown) => value is string;

                                                                                                                                                                                                              function null_

                                                                                                                                                                                                              null_: (value: unknown) => value is null;

                                                                                                                                                                                                                function nullOrUndefined

                                                                                                                                                                                                                nullOrUndefined: (value: unknown) => value is null;

                                                                                                                                                                                                                  function number

                                                                                                                                                                                                                  number: (value: unknown) => value is number;

                                                                                                                                                                                                                    function numericString

                                                                                                                                                                                                                    numericString: (value: unknown) => value is string;

                                                                                                                                                                                                                      function object

                                                                                                                                                                                                                      object: (value: unknown) => value is object;

                                                                                                                                                                                                                        function observable

                                                                                                                                                                                                                        observable: (value: unknown) => value is ObservableLike;

                                                                                                                                                                                                                          function oddInteger

                                                                                                                                                                                                                          oddInteger: (value: number) => value is number;

                                                                                                                                                                                                                            function plainObject

                                                                                                                                                                                                                            plainObject: <Value = unknown>(
                                                                                                                                                                                                                            value: unknown
                                                                                                                                                                                                                            ) => value is Record<string | number | symbol, Value>;

                                                                                                                                                                                                                              function primitive

                                                                                                                                                                                                                              primitive: (value: unknown) => value is Primitive;

                                                                                                                                                                                                                                function promise

                                                                                                                                                                                                                                promise: <T = unknown>(value: unknown) => value is Promise<T>;

                                                                                                                                                                                                                                  function propertyKey

                                                                                                                                                                                                                                  propertyKey: (value: unknown) => value is string | number | symbol;

                                                                                                                                                                                                                                    function regExp

                                                                                                                                                                                                                                    regExp: (value: unknown) => value is RegExp;

                                                                                                                                                                                                                                      function safeInteger

                                                                                                                                                                                                                                      safeInteger: (value: unknown) => value is number;

                                                                                                                                                                                                                                        function set

                                                                                                                                                                                                                                        set: <T = unknown>(value: unknown) => value is Set<T>;

                                                                                                                                                                                                                                          function sharedArrayBuffer

                                                                                                                                                                                                                                          sharedArrayBuffer: (value: unknown) => value is SharedArrayBuffer;

                                                                                                                                                                                                                                            function string

                                                                                                                                                                                                                                            string: (value: unknown) => value is string;

                                                                                                                                                                                                                                              function symbol

                                                                                                                                                                                                                                              symbol: (value: unknown) => value is symbol;

                                                                                                                                                                                                                                                function truthy

                                                                                                                                                                                                                                                truthy: (value: unknown) => boolean;

                                                                                                                                                                                                                                                  function typedArray

                                                                                                                                                                                                                                                  typedArray: (value: unknown) => value is TypedArray;

                                                                                                                                                                                                                                                    function uint16Array

                                                                                                                                                                                                                                                    uint16Array: (value: unknown) => value is Uint16Array;

                                                                                                                                                                                                                                                      function uint32Array

                                                                                                                                                                                                                                                      uint32Array: (value: unknown) => value is Uint32Array;

                                                                                                                                                                                                                                                        function uint8Array

                                                                                                                                                                                                                                                        uint8Array: (value: unknown) => value is Uint8Array;

                                                                                                                                                                                                                                                          function uint8ClampedArray

                                                                                                                                                                                                                                                          uint8ClampedArray: (value: unknown) => value is Uint8ClampedArray;

                                                                                                                                                                                                                                                            function undefined

                                                                                                                                                                                                                                                            undefined: (value: unknown) => value is undefined;

                                                                                                                                                                                                                                                              function urlInstance

                                                                                                                                                                                                                                                              urlInstance: (value: unknown) => value is URL;

                                                                                                                                                                                                                                                                function urlSearchParams

                                                                                                                                                                                                                                                                urlSearchParams: (value: unknown) => value is URLSearchParams;

                                                                                                                                                                                                                                                                  function urlString

                                                                                                                                                                                                                                                                  urlString: (value: unknown) => value is string;

                                                                                                                                                                                                                                                                    function weakMap

                                                                                                                                                                                                                                                                    weakMap: <Key extends object = object, Value = unknown>(
                                                                                                                                                                                                                                                                    value: unknown
                                                                                                                                                                                                                                                                    ) => value is WeakMap<Key, Value>;

                                                                                                                                                                                                                                                                      function weakSet

                                                                                                                                                                                                                                                                      weakSet: (value: unknown) => value is WeakSet<object>;

                                                                                                                                                                                                                                                                        Package Files (2)

                                                                                                                                                                                                                                                                        Dependencies (0)

                                                                                                                                                                                                                                                                        No dependencies.

                                                                                                                                                                                                                                                                        Dev Dependencies (16)

                                                                                                                                                                                                                                                                        Peer Dependencies (0)

                                                                                                                                                                                                                                                                        No peer dependencies.


                                                                                                                                                                                                                                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@sindresorhus/is.

                                                                                                                                                                                                                                                                        • Markdown
                                                                                                                                                                                                                                                                        • HTML
                                                                                                                                                                                                                                                                          <a href="https://www.jsdocs.io/package/@sindresorhus/is"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>