The `iserror` package, currently at version `0.0.2`, provides a lightweight utility function designed to determine if a given JavaScript value is an `Error` object. Released several years ago, it offers a simple, cross-environment solution for both Node.js and browser environments, as indicated by its keywords. Unlike Node.js's built-in `util.isError` (which has been deprecated since Node.js 10 and eventually removed), `iserror` functions as a standalone CommonJS module. Its primary differentiator is its singular focus on this specific type-checking task without introducing additional dependencies, providing a basic `require` interface for quick integration into projects that prefer a dedicated utility over direct `instanceof Error` checks or more complex custom type-guarding logic. Its release cadence appears to be minimal, reflecting a stable but largely unmaintained state since its initial publication.
npm install iserrorVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `isError` to differentiate between Error objects and other JavaScript values in a processing function.
Use `const isError = require('iserror');` for CommonJS environments. For ESM projects, rely on your bundler's CJS compatibility or consider modern alternatives like `value instanceof Error`.For new code, prefer `value instanceof Error` directly. For example: `if (myValue instanceof Error) { /* handle error */ }`. This provides the same functionality without an extra module.Evaluate your project's needs. For critical applications, `instanceof Error` is a more robust and future-proof solution maintained by the JavaScript engine itself.
Ensure you have `const isError = require('iserror');` at the top of your CommonJS file, or that your build system correctly transpiles ESM imports if you're using `import isError from 'iserror';`.Confirm that you are directly calling the result of `require('iserror')`, as it exports the function directly. `const isError = require('iserror'); isError(myValue);`No dependency data recorded yet.