Skip to content

Commit

Permalink
Refactor isError function
Browse files Browse the repository at this point in the history
  • Loading branch information
yefremov committed Mar 30, 2017
1 parent 52fabf4 commit 5d7eeab
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.js
Expand Up @@ -13,11 +13,10 @@ module.exports = isError;
*/

function isError(value) {
var tag = Object.prototype.toString.call(value);
return (
tag === '[object Error]' ||
tag === '[object Exception]' ||
tag === '[object DOMException]' ||
value instanceof Error
);
switch (Object.prototype.toString.call(value)) {
case '[object Error]': return true;
case '[object Exception]': return true;
case '[object DOMException]': return true;
default: return value instanceof Error;
}
}

0 comments on commit 5d7eeab

Please sign in to comment.