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

valid-types

v3.1.0

Published

A small JS type checker

Readme

valid-types

A lightweight, zero-dependency JavaScript/TypeScript type-checking utility. Provides reliable type guards for all built-in JS types, including edge cases like NaN, arguments, async functions, and ES6+ types (Map, Set, Promise, Symbol, etc.).

Installation

npm install valid-types
# or
yarn add valid-types

Usage

import { isString, isNumber, isArray } from 'valid-types';

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

CommonJS is also supported:

const { isString } = require('valid-types');

API

Primitives

| Function | Description | Example | |---|---|---| | isString(value) | true for string primitives | isString('hi')true | | isNumber(value) | true for finite numbers (excludes NaN) | isNumber(NaN)false | | isBoolean(value) | true for true / false | isBoolean(1)false | | isNull(value) | true only for null | isNull(null)true | | isUndefined(value) | true only for undefined | isUndefined(undefined)true | | isDefined(value) | true for anything except undefined | isDefined(null)true | | isNan(value) | true only for NaN (not string "NaN") | isNan(NaN)true | | isSymbol(value) | true for symbol primitives | isSymbol(Symbol())true |

Objects

| Function | Description | Example | |---|---|---| | isObject(value) | true for plain objects only (not null, Array, Date, etc.) | isObject({})true | | isArray(value) | true for arrays | isArray([])true | | isDate(value) | true for Date instances | isDate(new Date())true | | isRegExp(value) | true for RegExp instances | isRegExp(/abc/)true | | isMap(value) | true for Map instances | isMap(new Map())true | | isSet(value) | true for Set instances | isSet(new Set())true | | isError(value) | true for Error and subclasses | isError(new TypeError())true | | isArguments(value) | true for arguments objects (not array-likes) | — |

Functions

| Function | Description | Example | |---|---|---| | isFunction(value) | true for regular and arrow functions only | isFunction(() => {})true | | isClass(value) | true for ES6 class declarations | isClass(class Foo {})true | | isAsync(value) | true for async functions (not Promise instances) | isAsync(async () => {})true | | isPromise(value) | true for Promise instances | isPromise(Promise.resolve())true |

Strings & URLs

| Function | Description | Example | |---|---|---| | isUrl(value) | true for valid http:, https:, or ftp: URLs | isUrl('https://example.com')true | | isBase64(value) | true for base64 data URLs (data:...;base64,...) | isBase64('data:image/png;base64,abc')true |

Empty checks

| Function | Description | Example | |---|---|---| | isEmpty(value) | true for '', 0, '0', null, false, undefined | isEmpty('')true | | isEmptyObject(value) | true for plain objects with no own keys | isEmptyObject({})true | | isEmptyArray(value) | true for arrays with no elements | isEmptyArray([])true |

Generic

| Function | Returns | Example | |---|---|---| | isType(value) | String type name | isType(new Map())'map' |

Possible return values: 'string', 'number', 'NaN', 'boolean', 'undefined', 'null', 'symbol', 'object', 'array', 'date', 'regexp', 'map', 'set', 'error', 'promise', 'function', 'class', 'async', 'arguments', 'dom', 'document'

TypeScript

All functions ship with full TypeScript support. Where possible they are typed as proper type guards:

function processInput(value: unknown) {
  if (isString(value)) {
    // value is string here
    console.log(value.toUpperCase());
  }

  if (isArray(value)) {
    // value is unknown[] here
    value.forEach(console.log);
  }
}

Development

# run tests
npm test

# build
npm run build

# lint
npm run lint

# format
npm run format

License

MIT