Registry / type-stubs / is-lite

is-lite

JSON →
library2.0.0jsnpmunverified

is-lite is a concise and efficient JavaScript utility library for performing type checks and validations, currently at version 2.0.0. It offers a comprehensive suite of functions for identifying various data types, ranging from primitives like `string` and `number` to complex structures such as `Array`, `Map`, `class` constructors, and asynchronous functions. A core strength of is-lite is its robust TypeScript support, which includes type guards that facilitate accurate type inference within conditional statements, thereby improving code safety and developer experience. The library is designed to be lightweight, providing a minimal bundle size, and supports tree-shakeable, individual imports for each type checker from the `is-lite/standalone` path, optimizing performance in bundle-conscious environments. It maintains a consistent release cadence, with frequent updates incorporating new features and dependency upgrades, demonstrating active maintenance and evolution.

npm install is-lite
INSTALL
IMPORT
SIG · IS-LITE
I
is-lite
type-stubsjavascriptv2.0.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.

is
✓ import is from 'is-lite';
✗ const is = require('is-lite');
For ESM projects, use the default import. CommonJS `require('is-lite')` is also supported, returning the `is` object/function.
isString
✓ import { isString } from 'is-lite/standalone';
✗ import { isString } from 'is-lite'; const { isString } = require('is-lite');
Individual type checkers like `isString` are tree-shakeable and should be imported from the `is-lite/standalone` path. Importing them directly from 'is-lite' or destructuring via CJS require from the main package might not work or prevent tree-shaking.
isArrayOf
✓ import { isArrayOf } from 'is-lite';
Some specific checkers, like `isArrayOf`, are available as named exports directly from the main 'is-lite' package, often part of the main 'is' object's API.

Demonstrates importing the main `is` object and individual type checkers, then uses them to inspect various values and show type guards in action.

import is from 'is-lite'; import { isString, isInteger } from 'is-lite/standalone'; function processValue(value: unknown) { // Using the default 'is' function to get type string console.log(`Type of value: ${is(value)}`); // Using a specific type checker from the default import if (is.string(value)) { console.log(`Value is a string: "${value}"`); } // Using a specific type checker from standalone imports if (isString(value)) { console.log(`Value is definitely a string via isString: "${value}"`); } // Demonstrate a new checker from v2.0.0 if (isInteger(value)) { console.log(`Value is an integer: ${value}`); } // Example of is.arrayOf const mixedArray = ['a', 1, 'b']; const stringArray = ['hello', 'world']; console.log(`Is mixedArray all strings? ${is.arrayOf(mixedArray, is.string)}`); console.log(`Is stringArray all strings? ${is.arrayOf(stringArray, is.string)}`); } processValue('Hello, TypeScript'); processValue(42); processValue(null); processValue([1, 2, 3]);
Debug
Known issues
breakingVersion 2.0.0 introduced separate bundles for ESM and CommonJS. If you are using the `import` syntax, your bundler must correctly support ESM resolution for `is-lite`. Old CJS-only bundler configurations might break.
fix
Ensure your project's build tooling (e.g., Webpack, Rollup, Parcel, tsup) is configured to correctly handle ESM modules. For Node.js, ensure your package.json `type` field is set to `module` or use `.mjs` extensions for ESM files.
affects: >=2.0.0
breakingPrior to v1.2.0, the package's export structure was different. Specifically, named exports were not consistently available or structured as they are in current versions. Updates in v1.1.0 and v1.2.0 refined these exports.
fix
Review your import statements. If you were accessing utilities in a non-standard way, update to use `import is from 'is-lite'` for the main object or `import { isChecker } from 'is-lite/standalone'` for individual checkers.
affects: >=1.0.0 <1.2.0
gotchaThe `is.number()` function will return `false` for `NaN` (Not-a-Number). If you intend to specifically check for valid numeric values excluding `NaN`, this is the desired behavior. If `NaN` should be considered a number for your use case, use `is.nan()` in conjunction or check `typeof value === 'number'`.
fix
If `NaN` should be treated as a number, use `is.number(value) || is.nan(value)` or directly use `typeof value === 'number'` for a broader check. `is.numericString` will correctly identify string 'NaN'.
affects: >=0.9.0
gotchaThe `is.instanceOf(value, class)` checker only validates if `value` is a *direct* instance of the specified `class`. It does not check if `value` is an instance of a superclass in the prototype chain.
fix
To check against the full prototype chain, use JavaScript's native `value instanceof class` operator instead. For example, `new APIError() instanceof Error` would be `true`, while `is.instanceOf(new APIError(), Error)` is `false`.
affects: >=0.9.0
Errors
Common errors & fixes
TypeError: (0 , is_lite__WEBPACK_IMPORTED_MODULE_0__.isString) is not a function
Attempting to import `isString` or other individual checkers directly from `is-lite` instead of `is-lite/standalone` in an ESM context, or a bundler incorrectly resolving module paths.
fix
Change your import statement from `import { isString } from 'is-lite';` to `import { isString } from 'is-lite/standalone';`.
TypeError: is.isString is not a function
Attempting to access `isString` as a direct property of the default `is` object, while `isString` is intended for standalone import or direct call if `is` itself is a function.
fix
If you imported `is` as the main object, access specific checkers as `is.string(value)`. If you want the tree-shakeable `isString` function, import it directly via `import { isString } from 'is-lite/standalone';`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
is-lite — npm install is-lite · libregistry