1.0.0 • Published 1 month ago

error-constructor-verifier v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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, otherwise false.

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.0.0

1 month ago