`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-whatVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic type checking with `is-what`, including special handling for `NaN` and `isPlainObject`.
Migrate your project to use ES modules (`import`) or use a tool like `esm` if you cannot fully migrate.
Adjust your TypeScript code to explicitly narrow types or handle `unknown` correctly after `is-what` checks.
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.
Upgrade to `is-what@5.1.0` or newer to incorporate the security patch: `npm install is-what@latest`.
To check for a specific length, pass the desired length as the second argument: `isHexDecimal('idstring', 24)`.Change `const { someFn } = require('is-what')` to `import { someFn } from 'is-what'`.Explicitly narrow the type using a type assertion `(myVar as MyType).xyz` or perform further checks that TypeScript can use for inference.
If you need to check specifically if a value is `NaN`, use `isNaNValue(value)` instead.
No dependency data recorded yet.