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

nanotypes

v0.0.8

Published

Minimal, runtime-safe type checks for modern Vanilla JS

Readme

NanoTypes

npm gzip size downloads GitHub stars

Minimal, runtime-safe type guards for modern JavaScript.

Tree-shakable ESM bundle, zero-config, developer-friendly guards for typeof, instanceof, and structural checks.

  • Minified: ~2.5 KB
  • Gzipped: ~1.3 KB

Features

  • Runtime-safe typeof and instanceof matching
  • Dynamic support for global constructors (Map, URL, etc.)
  • Safe in Node, browsers, and workers (no browser-global crashes)
  • Non-throwing instanceof checks (runtime hardened)
  • Dev-only logging via globalThis.__DEV__ or NODE_ENV !== "production"
  • Auto-generated assertType.* versions
  • No dependencies
  • Works in any modern JS runtime (Node, browser, workers, edge)

Runtime Safety

NanoTypes is hardened for modern environments:

  • Safe access of globalThis constructors
  • No crashes from missing browser globals (e.g., HTMLElement in Node)
  • Defensive instanceof handling
  • Works consistently across Node, browsers, workers, and edge runtimes

Install

npm install nanotypes

Usage

import { is, assertType, describe } from 'nanotypes';

if (is.string("hello")) {
  console.log("It's a string!");
}

if (is(someValue, HTMLElement)) {
  someValue.focus();
}

if (is.textNode(document.createTextNode("x"))) {
  // Safe to access nodeValue, etc.
}

assertType.promise(Promise.resolve()); // throws TypeError if invalid

console.log(describe.value(new Map())); // "Map"

API

Generic Matcher

is(value, Class)
  • Uses instanceof internally
  • Logs warnings in development (globalThis.__DEV__ = true or when process.env.NODE_ENV !== "production")
  • Never throws — safely returns false on invalid constructor input

Type-Specific Guards

Over 60 guards are exposed automatically:

| Guard | Description | | ----------------------- | ---------------------------------------- | | is.string(x) | typeof x === "string" | | is.numberSafe(x) | Safe number (non-NaN) | | is.boolean(x) | Boolean primitive | | is.defined(x) | Not null or undefined | | is.nullish(x) | null or undefined | | is.array(x) | Array literal check | | is.object(x) | Non-null object, not array | | is.objectStrict(x) | Exactly a {} object | | is.plainObject(x) | Object with prototype Object or null | | is.func(x) | Function check | | is.map(x) | Instance of Map | | is.date(x) | Instance of Date | | is.error(x) | Instance of Error | | is.textNode(x) | DOM Text node | | is.htmlElement(x) | HTMLElement node | | is.contentEditable(x) | Editable DOM node | | is.positiveNumber(x) | Greater than 0 | | is.negativeNumber(x) | Less than 0 | | is.integer(x) | Whole number | | is.finite(x) | Not Infinity, not NaN | | is.truthy(x) | Coerces to true | | is.falsy(x) | Coerces to false |


Assertive Guards

All is.* functions have an assertType.* equivalent:

assertType.url(x) // throws TypeError if not a URL

Philosophy

Make JavaScript safer without making it heavier.

NanoTypes avoids boilerplate and unnecessary runtime bloat. Just clean, modern type guards ready for anything from browser UIs to CLI tools.


0.0.8

  • Hardened cross-runtime safety
  • Safe global constructor detection
  • Improved development-mode detection
  • Optimized bundled distribution for faster Node imports

License

DR.WATT v3.0