Skip to content

Commit c76f755

Browse files
committed
safer type checking for iterable structures
1 parent 56de89c commit c76f755

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/react/JSONTree/obj-type.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export default function(obj) {
2-
const type = Object.prototype.toString.call(obj).slice(8, -1);
3-
if (type === 'Object' && typeof obj[Symbol.iterator] === 'function') {
2+
if (obj !== null && typeof obj === 'object' && typeof obj[Symbol.iterator] === 'function') {
43
return 'Iterable';
54
}
6-
return type;
5+
return Object.prototype.toString.call(obj).slice(8, -1);
76
}

0 commit comments

Comments
 (0)