error-constructor-verifier
v1.0.0
Published
A lightweight npm package to check if a value is an error constructor. Useful for validating error constructors in JavaScript applications.
Downloads
4
Maintainers
Readme
error-constructor-verifier
A lightweight npm package to check if a value is an error constructor. Useful for validating error constructors in JavaScript applications.
Installation
You can install error-constructor-verifier via npm:
npm install error-constructor-verifier
Usage
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
API
isErrorConstructor(value)
value
: The value to check.- Returns
true
if the value is an error constructor, otherwisefalse
.
License
This project is licensed under the MIT License - see the LICENSE file for details.