Registry / serialization / is-what

is-what

JSON →
library5.5.0jsnpmunverified

`is-what` is a lightweight, fully TypeScript-supported utility library providing a comprehensive set of functions for JavaScript type checking, such as `isPlainObject()`, `isArray()`, `isString()`, and many more specific checks. Currently at version `5.5.0`, the library maintains a steady release cadence, frequently adding new type-checking utilities and dependency updates. Its core differentiators include a focus on simplicity, a small footprint, robust TypeScript type inference (automatically narrowing types after checks), and a more intuitive handling of edge cases like `NaN` compared to native JavaScript functions. It explicitly distinguishes between plain objects (`{}`) and class instances, addressing a common pain point in JavaScript development. The library aims to be a straightforward and reliable alternative to more complex or less type-safe existing solutions. Its `v5.x` releases moved to ESM-only and refined its TypeScript integration.

npm install is-what
INSTALL
IMPORT
SIG · IS-WHAT
I
is-what
serializationjavascriptv5.5.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isPlainObject
✓ import { isPlainObject } from 'is-what'
✗ const { isPlainObject } = require('is-what')
The library is ESM-only since v5.0.0. Use `import` statements.
isString
✓ import { isString } from 'is-what'
✗ import isString from 'is-what'
All functions are named exports; there is no default export.
isNaNValue
✓ import { isNaNValue } from 'is-what'
Use `isNaNValue` for explicit NaN checks, as `isNumber(NaN)` returns `false` in this library.

Demonstrates basic type checking with `is-what`, including special handling for `NaN` and `isPlainObject`.

import { isString, isNumber, isPlainObject, isArray, isDate, isNaNValue, isHexDecimal } from 'is-what'; console.log('Is "hello" a string?', isString('hello')); // true console.log('Is 123 a number?', isNumber(123)); // true console.log('Is NaN a number (is-what)?', isNumber(NaN)); // false, by design console.log('Is NaN truly NaN?', isNaNValue(NaN)); // true console.log('Is {} a plain object?', isPlainObject({})); // true console.log('Is new Date() a plain object?', isPlainObject(new Date())); // false console.log('Is [] an array?', isArray([])); // true console.log('Is new Date() a Date object?', isDate(new Date())); // true console.log('Is an invalid date a Date object?', isDate(new Date('invalid date'))); // false console.log('Is "60adf084f0fbdcab42de841e" a hex decimal of length 24?', isHexDecimal('60adf084f0fbdcab42de841e', 24)); // true
Debug
Known issues
breaking`is-what` became an ESM-only package in version 5.0.0. CommonJS `require()` statements will no longer work.
fix
Migrate your project to use ES modules (`import`) or use a tool like `esm` if you cannot fully migrate.
affects: >=5.0.0
breakingIn `v5.0.0`, type definitions were updated to use `unknown` instead of `any` for better type safety. This might cause TypeScript errors if your code relied on `any` for inferred types.
fix
Adjust your TypeScript code to explicitly narrow types or handle `unknown` correctly after `is-what` checks.
affects: >=5.0.0
gotchaThe `isNumber()` function in `is-what` explicitly returns `false` for `NaN`, differing from JavaScript's native `typeof NaN === 'number'` or `Number.isNaN()` behavior. Use `isNaNValue()` for specific `NaN` checks.
fix
When checking for numbers, be aware that `isNumber(NaN)` will be `false`. If you specifically need to check if a value is `NaN`, use the dedicated `isNaNValue()` function.
affects: >=1.0.0
securityVersion `5.1.0` included a fix for a security issue identified via `npm audit`. Users on older `v5.x` versions should upgrade.
fix
Upgrade to `is-what@5.1.0` or newer to incorporate the security patch: `npm install is-what@latest`.
affects: <5.1.0
gotchaThe `isHexDecimal` function, introduced in `v5.2.0`, accepts an optional second argument for checking a specific string length, useful for IDs like MongoDB ObjectIds. Omitting it will only check for valid hexadecimal characters.
fix
To check for a specific length, pass the desired length as the second argument: `isHexDecimal('idstring', 24)`.
affects: >=5.2.0
Errors
Common errors & fixes
TypeError [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/is-what/dist/index.js from ... not supported.
Attempting to use `require()` with `is-what` v5 and later, which is an ESM-only package.
fix
Change `const { someFn } = require('is-what')` to `import { someFn } from 'is-what'`.
Property 'xyz' does not exist on type 'unknown'.
After checking a variable with `is-what`, TypeScript still infers it as `unknown` due to the v5 update, preventing direct property access.
fix
Explicitly narrow the type using a type assertion `(myVar as MyType).xyz` or perform further checks that TypeScript can use for inference.
console.log(isNumber(NaN)); // Expected true, got false
`isNumber(NaN)` intentionally returns `false` in `is-what`.
fix
If you need to check specifically if a value is `NaN`, use `isNaNValue(value)` instead.
Upgrade
Version history
5.5.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
is-what — npm install is-what · libregistry