@n3okill/utils
Version:
Many javascript helpers
22 lines • 900 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.equalError = equalError;
const _internal_1 = require("./_internal");
const equalInstance_1 = require("./equalInstance");
/**
* If the two errors are of the same type, and have the same message, then they are equal
* @param {T} a - The first error to compare.
* @param {U} b - The error to compare against.
* @returns The result of the function call.
*/
function equalError(a, b) {
if (a.message !== b.message) {
return false;
}
const errorConstructors = [EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError];
if (errorConstructors.some((constructor) => (0, equalInstance_1.equalInstance)(constructor, a, b))) {
return true;
}
return (0, _internal_1.constructorName)(a) === (0, _internal_1.constructorName)(b);
}
//# sourceMappingURL=equalError.js.map
;