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

whether-is

v1.3.4

Published

A comprehensive, extensible, and type-friendly type and value checking utility for JavaScript/TypeScript.

Readme

whether-is

中文说明请见下方

A comprehensive, extensible, and type-friendly type and value checking utility for JavaScript/TypeScript.

For more awesome packages, check out my homepage💛

Features

  • Rich type and value checking: supports primitives, objects, arrays, classes, special values, and more
  • Handles edge cases (cross-realm, etc.)
  • TypeScript friendly, with type guards
  • Extensible and easy to use

Installation

npm install whether-is

Usage

import { whether } from 'whether-is';

whether.isString('abc'); // true
whether.isNumber(123); // true
whether.isArray([1, 2, 3]); // true
whether.isNullish(undefined); // true
whether.likeDate(new Date()); // true
whether.likePromise(Promise.resolve()); // true

// specially
whether.isNaN(NaN); // true
whether.isNaN(232); // false
whether.isNaN('abc'); // null <- not false!

API Highlights

  • is, equal(deep)
  • isString, isNumber, isBoolean, isNull, isUndefined, isSymbol, isBigInt
  • isObject, likeObject, isArray, isFunction, isClass, isArrowFunction
  • isEmpty, isEmptyObject, isEmptyArray, isNaN, isInteger, isSafeInteger, isSafeNumber, isFinite, isPrimitive, isField, isPropertyKey
  • likeError, likeDate, likePromise, likeSet, likeMap, likeWeakSet, likeWeakMap, likeRegExp
  • All orXXX methods support optional/undefined values

Notable Functions

  • isNaN:

    • Returns true only for the real NaN value, false for numbers, and null for non-number types (e.g. isNaN('abc') === null). This avoids the pitfalls of the global isNaN and is more type-safe.
  • likeXXX series (e.g. likeDate, likeSet, likePromise):

    • These check if an object is structurally similar to a built-in type, not just by instanceof, but by comparing all prototype property types. Useful for cross-realm/iframe and polyfilled objects.
  • isArrowFunction:

    • Detects arrow functions, even if not a standard function constructor. Handles most edge cases except proxied functions.
    • For precise results, see https://github.com/baendlorel/get-function-features
  • isClass:

    • Checks if a function is a class constructor, not just a plain function. Uses proxy and string analysis for accuracy.
    • For precise results, see https://github.com/baendlorel/get-function-features
  • isPromiseLike:

    • Checks if an object is a thenable (Promise A+ spec), not just a native Promise instance.
  • isEmpty, isEmptyObject, isEmptyArray:

    • Fine-grained checks for various empty states, including objects with no keys, arrays of length 0, and falsy values.

Edge Case Handling

  • Cross-realm (iframe) objects
  • Proxy objects
  • Custom class inheritance
  • Array-like objects

License

MIT


中文说明

一个全面、可扩展、类型友好的 JavaScript/TypeScript 类型和值判定工具库。

特性

  • 丰富的类型和值判定:支持原始类型、对象、数组、类、特殊值等
  • 处理各种边界情况(跨 iframe 等)
  • TypeScript 友好,类型守卫
  • 可扩展、易用

安装

npm install whether-is

用法示例

import { whether } from 'whether-is';

whether.isString('abc'); // true
whether.isNumber(123); // true
whether.isArray([1, 2, 3]); // true
whether.isNullish(undefined); // true
whether.likeDate(new Date()); // true
whether.likePromise(Promise.resolve()); // true

// 特别情况
whether.isNaN(NaN); // true
whether.isNaN(232); // false
whether.isNaN('abc'); // null <- 不是 false!

主要 API

  • is, equal(deep)
  • isString, isNumber, isBoolean, isNull, isUndefined, isSymbol, isBigInt
  • isObject, likeObject, isArray, isFunction, isClass, isArrowFunction
  • isEmpty, isEmptyObject, isEmptyArray, isNaN, isInteger, isSafeInteger, isSafeNumber, isFinite, isPrimitive, isField, isPropertyKey
  • likeError, likeDate, likePromise, likeSet, likeMap, likeWeakSet, likeWeakMap, likeRegExp
  • 所有 orXXX 方法支持可选/undefined 判定

特色判定函数

  • isNaN

    • 只对真正的 NaN 返回 true,对数字返回 false,对非数字类型(如字符串)返回 null,避免了全局 isNaN 的误判,更加类型安全。
  • likeXXX 系列(如 likeDate, likeSet, likePromise):

    • 不仅仅用 instanceof,还会比较原型链上所有属性的 typeof,能识别跨 iframe、polyfill 等场景的“类实例”。
  • isArrowFunction

    • 检测箭头函数,能区分普通函数和箭头函数(除 proxy 情况外)。
    • 更准确的判定参见:https://github.com/baendlorel/get-function-features
  • isClass

    • 判断一个函数是否为 class 构造器,而非普通函数。结合 proxy 和字符串分析,准确率高。
    • 更准确的判定参见:https://github.com/baendlorel/get-function-features
  • isPromiseLike

    • 判断对象是否为 Promise-like(thenable,符合 Promise A+ 规范),不仅限于原生 Promise。
  • isEmptyisEmptyObjectisEmptyArray

    • 细致区分各种“空”状态,包括无键对象、空数组、falsy 值等。

边界情况支持

  • 跨 iframe(跨全局环境)对象
  • Proxy 对象
  • 自定义类继承
  • 类数组对象

许可证

MIT