Skip to content

Commit

Permalink
Test value against DOMException
Browse files Browse the repository at this point in the history
  • Loading branch information
yefremov committed Mar 16, 2017
1 parent 16ae169 commit a11c4c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
module.exports = isError;

/**
* Test whether `V` is error object.
* Test whether `value` is error object.
*
* @param {*} V
* @param {*} value
* @returns {boolean}
*/

function isError(V) {
var tagName = Object.prototype.toString.call(V);
function isError(value) {
var tag = Object.prototype.toString.call(value);
return (
tagName === '[object Error]' ||
tagName === '[object Exception]' ||
V instanceof Error
tag === '[object Error]' ||
tag === '[object Exception]' ||
tag === '[object DOMException]' ||
value instanceof Error
);
}
3 changes: 1 addition & 2 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var test = require('tape');
var isError = require('.');

test('isError(V)', function (t) {
test('isError(value)', function (t) {
t.ok(new Error('Error'));
t.ok(new RangeError('Error'));
t.notOk(isError({}));
t.end();
});

0 comments on commit a11c4c2

Please sign in to comment.