Skip to content

Commit

Permalink
modify the check once again
Browse files Browse the repository at this point in the history
  • Loading branch information
todortotev committed Sep 22, 2020
1 parent cf19623 commit f7052e8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export type DataType =
| 'html_element'
| 'infinity'
| 'iterator'
| 'opaque_iterator'
| 'nan'
| 'null'
| 'number'
Expand Down Expand Up @@ -437,6 +438,8 @@ export function getDataType(data: Object): DataType {
return 'array_buffer';
} else if (typeof data[Symbol.iterator] === 'function') {
return 'iterator';
} else if (data[Symbol.iterator] === 'data') {
return 'opaque_iterator';
} else if (data.constructor && data.constructor.name === 'RegExp') {
return 'regexp';
} else {
Expand Down Expand Up @@ -615,11 +618,6 @@ export function formatDataForPreview(
}
case 'iterator':
const name = data.constructor.name;
// We check if the the generator returns itself.
// If it does, we want to avoid to iterate over it
if (typeof data[Symbol.iterator]() === 'object') {
return `${name}(${data.size})`;
}

if (showFormattedValue) {
// TRICKY
Expand Down Expand Up @@ -659,6 +657,9 @@ export function formatDataForPreview(
} else {
return `${name}(${data.size})`;
}
case 'opaque_iterator': {
return `${data.constructor.name}(${data.size})`;
}
case 'date':
return data.toString();
case 'object':
Expand Down

0 comments on commit f7052e8

Please sign in to comment.