Error.isError 


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.
Getting started
npm install --save error.iserror
Usage/Examples
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);
}
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);
assert.equal(isError(new DOMException()), true);
var shimIsError = require('error.iserror/shim');
const getPolyfill = require('error.iserror/polyfill');
var assert = require('assert');
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');
var shimmed = shimIsError();
assert.equal(shimmed, Error.isError);
assert.deepEqual(Error.isError(new Error()), isError(new Error()));
Tests
Simply clone the repo, npm install, and run npm test