Skip to content

Commit 491bd33

Browse files
author
Thomas Grainger
committed
support DOMException via iserror from npm
1 parent cb5e0df commit 491bd33

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"main": "src/singleton.js",
1616
"dependencies": {
17+
"iserror": "^0.0.2",
1718
"json-stringify-safe": "^5.0.1"
1819
},
1920
"devDependencies": {

src/utils.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
'use strict';
22

3+
var isError = require('iserror');
4+
35
function isObject(what) {
46
return typeof what === 'object' && what !== null;
57
}
68

7-
// Sorta yanked from https://github.com/joyent/node/blob/aa3b4b4/lib/util.js#L560
8-
// with some tiny modifications
9-
function isError(what) {
10-
var toString = {}.toString.call(what);
11-
return isObject(what) &&
12-
toString === '[object Error]' ||
13-
toString === '[object Exception]' || // Firefox NS_ERROR_FAILURE Exceptions
14-
what instanceof Error;
15-
}
16-
179
module.exports = {
1810
isObject: isObject,
1911
isError: isError
20-
};
12+
};

0 commit comments

Comments
 (0)