Registry / testing / is
library3.3.2jsnpmunverified

The `is` library is a lightweight, comprehensive JavaScript utility designed for type and value testing. It provides a rich API to determine the type or specific characteristics of a variable, offering functions like `is.string()`, `is.array()`, `is.empty()`, `is.equal()`, and many more for common JavaScript types and states. Currently stable at version 3.3.2, the package maintains a steady but not rapid release cadence, primarily focusing on bug fixes and dependency updates. Its key differentiator is the extensive, declarative API that simplifies complex type checks, often replacing verbose `typeof` or `instanceof` chains, making code more readable and robust. It's widely used in both Node.js and browser environments for input validation, conditional logic, and defensive programming.

npm install is
INSTALL
IMPORT
SIG · IS
I
is
testingjavascriptv3.3.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

is
import is from 'is';
import { is } from 'is'; // Incorrect named import, 'is' is the default export const is = require('is'); // Correct for CommonJS
The library primarily exposes its utilities via a default export (a single object named 'is'). While older Node.js versions use `require('is')`, modern ESM-driven environments should use `import is from 'is';`. Individual functions are then accessed as properties of the `is` object (e.g., `is.string('hello')`).
is.string
import is from 'is'; is.string('hello');
import { string } from 'is'; // 'string' is a property of the 'is' object, not a named export const string = require('is').string; // CommonJS, but less common to destructure 'is'
Most type-checking functions are properties of the main 'is' object. There are no direct named exports for individual type checks like `string`, `array`, etc. Always import the main 'is' object first.
is.defined
import is from 'is'; if (is.defined(myVar)) { /* ... */ }
import { defined } from 'is'; // 'defined' is a property of the 'is' object, not a named export
Similar to `is.string`, all utility methods like `is.defined`, `is.empty`, `is.nil`, etc., are accessed as properties of the main `is` object obtained via the default import or CommonJS require.

Demonstrates importing the 'is' library and using various type-checking functions like `is.nil`, `is.string`, `is.array`, `is.object`, `is.empty`, `is.defined`, and `is.type` for conditional logic.

import is from 'is'; function processValue(value) { if (is.nil(value)) { console.log('Value is null or undefined.'); return 'default_value'; } else if (is.string(value)) { console.log(`Value is a string: ${value}`); return value.trim(); } else if (is.array(value)) { console.log(`Value is an array with ${value.length} elements.`); return value.filter(item => is.defined(item)); } else if (is.object(value) && is.empty(value)) { console.log('Value is an empty object.'); return {}; } else { console.log(`Value is of type: ${is.type(value)}`); return value; } } console.log(processValue(null)); console.log(processValue(' hello world ')); console.log(processValue([1, undefined, 3])); console.log(processValue({})); console.log(processValue(123)); console.log(processValue(new Date()));
Debug
Known issues
breakingA critical supply chain attack occurred, leading to the publication of malicious versions of the 'is' package. Specifically, versions 3.3.1 and 5.0.0 released on July 19, 2025, were compromised and contained malicious code. These versions were promptly removed from npm.
fix
Immediately upgrade to version 3.3.2 or later, or ensure you are using a version prior to the compromised releases (e.g., 3.3.0). Always verify the integrity of your installed packages, especially after major security incidents. Use `npm audit` regularly.
affects: 3.3.1, 5.0.0
deprecatedSeveral functions like `is.instanceof`, `is.null`, and `is.undefined` are formally deprecated within the library. While they still function, their use is discouraged.
fix
Replace `is.instanceof(value, constructor)` with `is.instance(value, constructor)`. For `is.null(value)` use `value === null`. For `is.undefined(value)` use `value === undefined` or `is.undef(value)`. Consider using `is.nil(value)` for a check against both null and undefined.
affects: >=3.x
gotchaThe package does not officially declare itself as an ES Module (`"type": "module"` in `package.json` or explicit `.mjs` files). While modern bundlers and Node.js can typically consume CommonJS modules via `import`, direct ESM consumption might lead to unexpected behavior or require specific tooling configurations.
fix
For optimal compatibility in ESM-only environments, ensure your build setup (e.g., Webpack, Rollup, Parcel, or TypeScript's `moduleResolution`) is configured to correctly handle CommonJS modules. If issues persist, consider using a different type-checking library that explicitly offers native ESM support.
affects: <3.x
Errors
Common errors & fixes
TypeError: is.string is not a function
Attempting to access a type-checking function directly from a named import or an incorrectly structured CommonJS import.
fix
Ensure you are importing the entire `is` object as the default export (ESM: `import is from 'is';`) or requiring the entire module (CommonJS: `const is = require('is');`). All type functions are properties of this 'is' object, e.g., `is.string('value')`.
ERR_REQUIRE_ESM: require() of ES Module ... not supported
This library is primarily CommonJS, but if a dependency *within* `is` or another part of your project incorrectly uses `"type": "module"` and is then `require()`-d, this error can occur.
fix
This error is typically not caused by `is` itself unless you are using a compromised or improperly bundled version. Verify your project's `package.json` `type` field and module resolution settings. For `is` specifically, ensure you are on a non-compromised version (>=3.3.2) and that your environment correctly handles CJS interop for `require` or uses `import` as appropriate.
Upgrade
Version history
3.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
is — npm install is · libregistry