{"id":15126,"library":"is-lite","title":"is-lite: Lightweight Type Checking","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/gilbarbara/is-lite","tags":["javascript","type","check","assertion","validation","test","typeguard","typeof","instanceof","typescript"],"install":[{"cmd":"npm install is-lite","lang":"bash","label":"npm"},{"cmd":"yarn add is-lite","lang":"bash","label":"yarn"},{"cmd":"pnpm add is-lite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For ESM projects, use the default import. CommonJS `require('is-lite')` is also supported, returning the `is` object/function.","wrong":"const is = require('is-lite');","symbol":"is","correct":"import is from 'is-lite';"},{"note":"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.","wrong":"import { isString } from 'is-lite';\nconst { isString } = require('is-lite');","symbol":"isString","correct":"import { isString } from 'is-lite/standalone';"},{"note":"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.","symbol":"isArrayOf","correct":"import { isArrayOf } from 'is-lite';"}],"quickstart":{"code":"import is from 'is-lite';\nimport { isString, isInteger } from 'is-lite/standalone';\n\nfunction processValue(value: unknown) {\n  // Using the default 'is' function to get type string\n  console.log(`Type of value: ${is(value)}`);\n\n  // Using a specific type checker from the default import\n  if (is.string(value)) {\n    console.log(`Value is a string: \"${value}\"`);\n  }\n\n  // Using a specific type checker from standalone imports\n  if (isString(value)) {\n    console.log(`Value is definitely a string via isString: \"${value}\"`);\n  }\n\n  // Demonstrate a new checker from v2.0.0\n  if (isInteger(value)) {\n    console.log(`Value is an integer: ${value}`);\n  }\n\n  // Example of is.arrayOf\n  const mixedArray = ['a', 1, 'b'];\n  const stringArray = ['hello', 'world'];\n  console.log(`Is mixedArray all strings? ${is.arrayOf(mixedArray, is.string)}`);\n  console.log(`Is stringArray all strings? ${is.arrayOf(stringArray, is.string)}`);\n}\n\nprocessValue('Hello, TypeScript');\nprocessValue(42);\nprocessValue(null);\nprocessValue([1, 2, 3]);","lang":"typescript","description":"Demonstrates importing the main `is` object and individual type checkers, then uses them to inspect various values and show type guards in action."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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.","message":"Prior 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.","severity":"breaking","affected_versions":">=1.0.0 <1.2.0"},{"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'.","message":"The `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'`.","severity":"gotcha","affected_versions":">=0.9.0"},{"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`.","message":"The `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.","severity":"gotcha","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Change your import statement from `import { isString } from 'is-lite';` to `import { isString } from 'is-lite/standalone';`.","cause":"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.","error":"TypeError: (0 , is_lite__WEBPACK_IMPORTED_MODULE_0__.isString) is not 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';`.","cause":"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.","error":"TypeError: is.isString is not a function"}],"ecosystem":"npm"}