
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
error.iserror
Advanced tools
An ESnext spec-compliant `Error.isError` shim/polyfill/replacement that works as far down as ES3
An ESnext spec-compliant Error.isError shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.
npm install --save error.iserror
const isError = require('error.iserror');
var assert = require('assert');
assert.equal(isError(undefined), false);
assert.equal(isError(null), false);
assert.equal(isError({}), false);
assert.equal(isError([]), false);
assert.equal(isError(Error), false);
assert.equal(isError({ __proto__: Error.prototype, constructor: Error }), false);
assert.equal(isError(new Error()), true);
assert.equal(isError(new EvalError()), true);
assert.equal(isError(new RangeError()), true);
assert.equal(isError(new ReferenceError()), true);
assert.equal(isError(new SyntaxError()), true);
assert.equal(isError(new TypeError()), true);
assert.equal(isError(new URIError()), true);
if (typeof AggregateError === 'function') {
assert.equal(isError(new AggregateError([])), true);
}
if (typeof SuppressedError === 'function') {
assert.equal(isError(new SuppressedError()), true);
}
// note: engines that have `Symbol.toStringTag`, and lack structuredClone, and lack other brand-checking
// mechanisms, are only capable of brand-checking Error objects when they lack a `Symbol.toStringTag` property in their
// prototype chain. An object with it will give the wrong answer.
// This affects node 6 - 9, Chrome 49 - 97, Safari 10 - 14, Edge 15 - 18
assert.equal(isError({ __proto__: Error.prototype, constructor: Error, [Symbol.toStringTag]: 'Error' }), false);
const err = Object.assign(new Error(), { [Symbol.toStringTag]: 'Non-Error' });
Object.setPrototypeOf(err, null);
assert.equal(isError(err), true);
var shimIsError = require('error.iserror/shim');
const getPolyfill = require('error.iserror/polyfill');
var assert = require('assert');
/* when Error.isError is not present */
delete Error.isError;
var shimmed = shimIsError();
assert.equal(shimmed, getPolyfill());
assert.deepEqual(Error.isError(new Error()), isError(new Error()));
var shimIsError = require('error.iserror/shim');
var assert = require('assert');
/* when Error.isError is present */
var shimmed = shimIsError();
assert.equal(shimmed, Error.isError);
assert.deepEqual(Error.isError(new Error()), isError(new Error()));
Simply clone the repo, npm install, and run npm test
FAQs
An ESnext spec-compliant `Error.isError` shim/polyfill/replacement that works as far down as ES3
The npm package error.iserror receives a total of 38 weekly downloads. As such, error.iserror popularity was classified as not popular.
We found that error.iserror demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.