Awesome
is-typeof-error
Check that given value is any type of error and instanceof Error.
Install
npm i is-typeof-error --save
Usage
For more use-cases see the tests
const isTypeofError = require('is-typeof-error')
isTypeofError
Check that
val
is error.
Params
val
{Error}returns
{Boolean}
Example
const isTypeofError = require('is-typeof-error')
const PluginError = require('plugin-error')
const KindError = require('kind-error')
const CustomClass = function () {}
CustomClass.prototype.foo = function () {}
isTypeofError(new TypeError('test')) // => true
isTypeofError(new KindError('test')) // => true
isTypeofError(new SyntaxError('test')) // => true
isTypeofError(new PluginError('test', 'msg')) // => true
isTypeofError(new CustomClass('test')) // => false
isTypeofError(new Object({a: 'b'})) // => false
isTypeofError(new RegExp('test')) // => false
isTypeofError(Object.create({a: 'b'})) // => false
isTypeofError(/regex/) // => false
isTypeofError({a: 'b'}) // => false
Related
- error-base: Create custom Error classes. | homepage
- is-kindof: Check type of given javascript value. Support promises, generators, streams, and native types… more | homepage
- kind-error: Base class for easily creating meaningful and quiet by default Error classes with sane… more | homepage
- kind-of: Get the native type of a value. | homepage
- kind-of-extra: Additional functionality to
kind-of
type check utility, support promises, generators… more | homepage - kind-of-types: List of all javascript types. Used and useful for checking, validation, sanitizing and… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.