npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

is-type-check-util

v1.0.4

Published

Lightweight, tree-shakeable type-checking utilities for JavaScript and TypeScript

Readme

is-type-check-util

npm version npm downloads

Lightweight, tree-shakeable type-checking utilities for JavaScript and TypeScript. Zero dependencies. Full TypeScript type narrowing support.

Why is-type-check-util?

  • Tiny — 5 KB packed, tree-shake down to bytes
  • Zero dependencies — nothing extra to install
  • Dual API — unified isType(val, 'string') + standalone isString(val) helpers
  • TypeScript-first — every helper is a type predicate for automatic narrowing
  • 30+ type checks — primitives, objects, collections, functions, buffers, and more
  • Dual format — ships both ESM and CommonJS
  • Case-insensitiveisType([], 'Array') just works

Installation

npm install is-type-check-util
yarn add is-type-check-util
pnpm add is-type-check-util

Usage

Unified isType() API

A single function that accepts any value and a type name string:

import { isType } from 'is-type-check-util';

isType('hello', 'string');       // true
isType(42, 'number');            // true
isType([], 'array');             // true
isType(null, 'null');            // true
isType(new Date(), 'date');      // true
isType(new Map(), 'map');        // true
isType(async () => {}, 'asyncfunction'); // true
isType({}, 'plainobject');       // true

// Case-insensitive
isType([], 'Array');             // true
isType(new Set(), 'SET');        // true

// Throws on unknown types
isType('hello', 'foo');          // Error: Unknown type: "foo"

Standalone helpers

Import only what you need — each function is independently tree-shakeable:

import { isString, isArray, isPlainObject } from 'is-type-check-util';

isString('hello');    // true
isString(42);         // false

isArray([1, 2, 3]);   // true
isArray('not array'); // false

isPlainObject({});              // true
isPlainObject(new Date());      // false
isPlainObject(Object.create(null)); // true

Primitives

import { isNumber, isBoolean, isNull, isUndefined, isSymbol, isBigInt } from 'is-type-check-util';

isNumber(42);            // true
isNumber(NaN);           // true (NaN is technically a number)
isBoolean(false);        // true
isNull(null);            // true
isUndefined(undefined);  // true
isSymbol(Symbol('id'));  // true
isBigInt(42n);           // true

Objects and collections

import { isDate, isRegExp, isMap, isSet, isWeakMap, isWeakSet, isObject } from 'is-type-check-util';

isDate(new Date());      // true
isRegExp(/abc/);         // true
isMap(new Map());        // true
isSet(new Set());        // true
isWeakMap(new WeakMap()); // true
isWeakSet(new WeakSet()); // true
isObject({});            // true (any non-null object)
isObject(null);          // false

Functions

import { isFunction, isAsyncFunction, isGeneratorFunction } from 'is-type-check-util';

isFunction(() => {});                 // true
isAsyncFunction(async () => {});      // true
isGeneratorFunction(function* () {}); // true

Errors, buffers, and more

import { isError, isBuffer, isArrayBuffer, isTypedArray, isPromise } from 'is-type-check-util';

isError(new TypeError('oops'));  // true
isBuffer(Buffer.from('data'));   // true
isArrayBuffer(new ArrayBuffer(8)); // true
isTypedArray(new Uint8Array(4)); // true
isPromise(Promise.resolve());    // true
isPromise({ then: () => {} });   // true (thenable)

Utility checks

import { isNil, isNaN, isFinite, isInteger, isArguments } from 'is-type-check-util';

isNil(null);        // true
isNil(undefined);   // true
isNil(0);           // false

isNaN(NaN);         // true
isNaN('hello');     // false (stricter than global isNaN)

isFinite(42);       // true
isFinite(Infinity); // false

isInteger(10);      // true
isInteger(10.5);    // false

TypeScript type narrowing

All standalone helpers are type predicates, so TypeScript narrows automatically:

import { isString, isArray } from 'is-type-check-util';

function process(input: unknown) {
  if (isString(input)) {
    console.log(input.toUpperCase()); // input is string
  }
  if (isArray(input)) {
    console.log(input.length);        // input is unknown[]
  }
}

Supported types

| Type name | Checker function | Category | |---|---|---| | string | isString | Primitive | | number | isNumber | Primitive | | boolean | isBoolean | Primitive | | null | isNull | Primitive | | undefined | isUndefined | Primitive | | symbol | isSymbol | Primitive | | bigint | isBigInt | Primitive | | array | isArray | Object | | object | isObject | Object | | plainobject | isPlainObject | Object | | date | isDate | Object | | regexp | isRegExp | Object | | map | isMap | Collection | | set | isSet | Collection | | weakmap | isWeakMap | Collection | | weakset | isWeakSet | Collection | | function | isFunction | Function | | asyncfunction | isAsyncFunction | Function | | generatorfunction | isGeneratorFunction | Function | | error | isError | Error | | buffer | isBuffer | Buffer | | arraybuffer | isArrayBuffer | Buffer | | typedarray | isTypedArray | Buffer | | promise | isPromise | Utility | | nan | isNaN | Utility | | finite | isFinite | Utility | | integer | isInteger | Utility | | arguments | isArguments | Utility | | nil | isNil | Utility |

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

MIT