$ cnpm install is-typeof-error
Check that given value is any type of error and instanceof Error.
npm i is-typeof-error --save
For more use-cases see the tests
const isTypeofError = require('is-typeof-error')
Check that
valis 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
kind-of type check utility, support promises, generators… more | homepagePull 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.
Copyright 2013 - present © cnpmjs.org | Home |