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

@wicle/is

v2.1.0

Published

Runtime type checking library for JavaScript and TypeScript with precise type identification

Readme

@wicle/is

Runtime type-checking library for JavaScript and TypeScript with precise, non-overlapping type identification.

Each type check is mutually exclusive: if a value is identified as one type, it will not match any other type in this library. For example, a class constructor returns true for isClass but false for isFunction and isObject.

Installation

npm install @wicle/is
# or
pnpm add @wicle/is
# or
yarn add @wicle/is

Usage

Default import

import is from "@wicle/is";

is.isString("hello"); // true
is.isNumber(42); // true
is.isArray([1, 2, 3]); // true

Individual imports

import { isString, isNumber, isArray } from "@wicle/is";

isString("hello"); // true
isNumber(42); // true
isArray([1, 2, 3]); // true

API

All functions return true if the value matches the type, false otherwise. Each function is a TypeScript type guard that narrows the type in the enclosing scope.

| Function | TypeScript narrowed type | Description | | -------------------- | ------------------------------------------ | --------------------------------------- | | isArray(a) | unknown[] | Array | | isObject(a) | Record<string, unknown> | Plain object or class instance | | isFunction(a) | (...args: unknown[]) => unknown | Regular or async function (not a class) | | isString(a) | string | String | | isNumber(a) | number | Number | | isDate(a) | Date | Date | | isRegExp(a) | RegExp | RegExp | | isError(a) | Error | Error | | isSymbol(a) | symbol | Symbol | | isMap(a) | Map<unknown, unknown> | Map | | isWeakMap(a) | WeakMap<WeakKey, unknown> | WeakMap | | isSet(a) | Set<unknown> | Set | | isWeakSet(a) | WeakSet<WeakKey> | WeakSet | | isClass(a) | new (...args: unknown[]) => unknown | Class constructor | | isPromise(a) | — | Thenable object (duck-typed) | | isAsyncFunction(a) | (...args: unknown[]) => Promise<unknown> | Async function | | isGlob(a) | Glob | String or readonly string array |

The exported Glob type is string | readonly string[].

Utility functions

arrayify(arg: T)

Make the argument to be array type if it is not already in srray type.

function(arg: string | string[]) {
    const argList = arrayify(arg);
    // ...
}

Type narrowing

function process(value: unknown) {
    if (isString(value)) {
        console.log(value.toUpperCase()); // value: string
    } else if (isArray(value)) {
        console.log(value.length); // value: unknown[]
    } else if (isFunction(value)) {
        value(); // value: (...args: unknown[]) => unknown
    } else if (isClass(value)) {
        new value(); // value: new (...args: unknown[]) => unknown
    }
}

Type overlap behaviour

isFunction vs isClass vs isAsyncFunction

isFunction returns true for regular and async functions, but false for class constructors. Use isClass to check for classes specifically, or isAsyncFunction to check exclusively for async functions.

class MyClass {}
const fn = () => {};
const asyncFn = async () => {};

isClass(MyClass); // true
isFunction(MyClass); // false

isFunction(fn); // true
isAsyncFunction(fn); // false

isFunction(asyncFn); // true  — async functions are still functions
isAsyncFunction(asyncFn); // true
isClass(asyncFn); // false

isObject and class instances

isObject returns true for both plain objects and class instances. It returns false for arrays, functions, classes, and primitives.

class MyClass {}
const instance = new MyClass();

isObject({}); // true
isObject(instance); // true
isObject([]); // false
isObject(MyClass); // false

isPromise

isPromise uses duck-typing: it returns true for any non-null object with a .then method (i.e., a thenable). This matches native Promise, resolved values from other libraries, and custom thenable objects.

isPromise(Promise.resolve(1)); // true
isPromise({ then: () => {} }); // true
isPromise(async () => {}); // false — async functions are not thenables

License

MIT