A lightweight npm package to check if a value is an error constructor. Useful for validating error constructors in JavaScript applications.
You can install error-constructor-verifier via npm:
npm install error-constructor-verifier
const isErrorConstructor = require('error-constructor-verifier');
// Check if Error is an error constructor
console.log(isErrorConstructor(Error)); // Output: true
// Check if TypeError is an error constructor
console.log(isErrorConstructor(TypeError)); // Output: true
// Check if String is an error constructor
console.log(isErrorConstructor(String)); // Output: false
// Check if 42 is an error constructor
console.log(isErrorConstructor(42)); // Output: false
value
: The value to check.- Returns
true
if the value is an error constructor, otherwisefalse
.
This project is licensed under the MIT License - see the LICENSE file for details.