is-constructor
v1.1.1
Published
Check if a value is a constructor function
Downloads
104
Maintainers
Readme
is-constructor
This utility function determines whether a given value is a constructor function. It performs a series of checks to accurately identify constructors, including class constructors and legacy function constructors.
Key features:
- Accurately identifies both modern class constructors and legacy function constructors
- Handles edge cases and corner cases
- Written in TypeScript with full type support
- Lightweight with no dependencies
While the current implementation is robust, I'm always open to suggestions for improvements or optimizations. If you have ideas on how to enhance the accuracy or performance of the checks, please feel free to submit a pull request or open an issue for discussion.
Usage
ES5/NodeJS:
var isConstructor = require("is-constructor");
isConstructor(/* your thing to test */);
ES6/TypeScript:
import * as isConstructor from "is-constructor";
isConstructor(/* your thing to test */);