Skip to content

Commit 5ca6f60

Browse files
committed
[Robustness] use typeof instead of comparing to literal undefined
1 parent 81edd34 commit 5ca6f60

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ var objectToString = Object.prototype.toString;
1111

1212
module.exports = function inspect_ (obj, opts, depth, seen) {
1313
if (!opts) opts = {};
14-
15-
var maxDepth = opts.depth === undefined ? 5 : opts.depth;
16-
if (depth === undefined) depth = 0;
14+
15+
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
16+
if (typeof depth === 'undefined') depth = 0;
1717
if (depth >= maxDepth && maxDepth > 0 && obj && typeof obj === 'object') {
1818
return '[Object]';
1919
}
20-
21-
if (seen === undefined) seen = [];
20+
21+
if (typeof seen === 'undefined') seen = [];
2222
else if (indexOf(seen, obj) >= 0) {
2323
return '[Circular]';
2424
}

0 commit comments

Comments
 (0)