is-typeof-error
Check that given value is any type of error and instanceof Error.
Last updated 10 years ago by tunnckocore .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-typeof-error 
SYNC missed versions from official npm registry.

is-typeof-error npmjs.com The MIT License

Check that given value is any type of error and instanceof Error.

code climate standard code style travis build status coverage status dependency status

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

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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Current Tags

  • 1.1.0                                ...           latest (10 years ago)

4 Versions

  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
  • 0.0.0                                ...           11 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |