is-error-constructor
Version:
Check if a value is an error constructor
34 lines (22 loc) • 504 B
Markdown
> Check if a value is an error constructor
```
$ npm install is-error-constructor
```
```js
import isErrorConstructor from 'is-error-constructor';
isErrorConstructor(Error);
//=> true
isErrorConstructor(RangeError);
//=> true
function FakeError() {}
isErrorConstructor(FakeError);
//=> false
class UnicornError extends Error {}
isErrorConstructor(UnicornError);
//=> true
```
- [is](https://github.com/sindresorhus/is) - Type check values