npm.io
3.0.0 • Published 5 years ago

is-error-constructor

Licence
MIT
Version
3.0.0
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
14

is-error-constructor

Check if a value is an error constructor

Install

$ npm install is-error-constructor

Usage

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 - Type check values

Keywords