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

js-type-guard

v0.0.4

Published

Lightweight, zero-dependency runtime type-check utilities for JavaScript and TypeScript — fast, reliable, and TypeScript-friendly tools to guard your code and ship with confidence.

Readme

js-type-guard 🚀

Lightweight, fast, and practical type-check utilities for JavaScript and TypeScript developers. js-type-guard gives you a small set of predictable helpers to check runtime values — clear API, zero fuss, ready for production. ✨

Why choose js-type-guard? 🎯

  • Minimal and focused: a compact collection of common type checks (strings, numbers, arrays, dates, regex, etc.).
  • Predictable results: simple boolean utilities you can rely on in runtime guards and validation flows.
  • TypeScript-friendly: shipped with TypeScript declarations so IDEs give great autocomplete and hints.
  • Zero dependencies: tiny footprint, easy to audit and include in any project.

Install

npm install js-type-guard
# or
yarn add js-type-guard

Quick start — JavaScript (CommonJS)

const { isString, isArray, WTF } = require('js-type-guard');

console.log(isString('hello')); // true
console.log(isArray([1,2,3])); // true
console.log(WTF([1,2,3])); // 'array' 😄

Plain JavaScript — Node.js (require)

If you're using plain Node.js with CommonJS modules, you can require the whole module or destructure the helpers.

// destructure specific helpers
const { isString, WTF } = require('js-type-guard');

console.log(isString('hello')); // true
console.log(WTF(/abc/)); // 'regexp' 🎯

// or require the module as an object
const jsType = require('js-type-guard');
console.log(jsType.WTF(new Date())); // 'date'

Quick start — TypeScript / ESM

import { isNumber, isRegExp, WTF } from 'js-type-guard';

if (isNumber(value)) {
  // runtime check passed — value is a number at runtime
}

const rx = /abc/;
console.log(isRegExp(rx)); // true
console.log(WTF(rx)); // 'regexp' 🎯

Class usage (optional)

import { Type } from 'js-type-guard';

console.log(Type.isString('a')); // true
console.log(Type.isNull(null)); // true
console.log(Type.WTF(new Date())); // 'date'

API

| Function | Description | Returns | |---------------------|---------------------------------------------------------------------------------------------------|----------:| | isString(value) | Checks if value is a string (primitive or String object) | boolean | | isNumber(value) | Checks if value is a number (primitive or Number object) | boolean | | isBoolean(value) | Checks if value is a boolean | boolean | | isDate(value) | Checks if value is a Date instance | boolean | | isFunction(value) | Checks if value is a function | boolean | | isArray(value) | Checks if value is an Array | boolean | | isObject(value) | Checks if value is a plain Object ("[object Object]") | boolean | | isUndefined(value) | Checks if value is undefined | boolean | | isNull(value) | Checks if value is null | boolean | | isRegExp(value) | Checks if value is a RegExp instance | boolean | | isMap(value) | Checks if value is a Map instance | boolean | | isSet(value) | Checks if value is a Set instance | boolean | | isSymbol(value) | Checks if value is a Symbol | boolean | | isError(value) | Checks if value is an Error instance | boolean | | isBigInt(value) | Checks if value is a BigInt | boolean | | isArguments(value) | Checks if value is an arguments object | boolean | | isTypedArray(value) | Checks if value is a TypedArray (e.g., Int8Array, Uint8Array) | boolean | | WTF(value) | Returns the runtime type string (lowercased, e.g. 'array', 'date', 'regexp', 'null', 'undefined') | string |

Each boolean function returns whether the runtime value matches the check. WTF returns the runtime type string (lowercased) using Object.prototype.toString.call(value) for highest accuracy.

Best practices 🌟

  • Use these helpers as runtime guards before performing operations that assume a certain shape or type.
  • In TypeScript projects you can combine these runtime checks with type narrowing patterns — consider updating the helpers to return type predicates (value is T) for even tighter integration.

Contributing & Support 💬

Contributions, issues and feature requests are welcome. Please open an issue or a PR.

License

MIT