Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename from iterator to iterable and split the functionality #19831

Merged
merged 9 commits into from
Sep 22, 2020
11 changes: 8 additions & 3 deletions packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ export type DataType =
| 'html_all_collection'
| 'html_element'
| 'infinity'
| 'iterator'
| 'iterable'
| 'opaque_iterable'
| 'nan'
| 'null'
| 'number'
Expand Down Expand Up @@ -435,8 +436,10 @@ export function getDataType(data: Object): DataType {
// If it doesn't error, we know it's an ArrayBuffer,
// but this seems kind of awkward and expensive.
return 'array_buffer';
} else if (data[Symbol.iterator]() === 'data') {
todortotev marked this conversation as resolved.
Show resolved Hide resolved
return 'opaque_iterable';
} else if (typeof data[Symbol.iterator] === 'function') {
return 'iterator';
return 'iterable';
} else if (data.constructor && data.constructor.name === 'RegExp') {
return 'regexp';
} else {
Expand Down Expand Up @@ -613,7 +616,7 @@ export function formatDataForPreview(
} else {
return shortName;
}
case 'iterator':
case 'iterable':
const name = data.constructor.name;
if (showFormattedValue) {
// TRICKY
Expand Down Expand Up @@ -653,6 +656,8 @@ export function formatDataForPreview(
} else {
return `${name}(${data.size})`;
}
case 'opaque_iterable':
return `${name}(${data.size})`;
case 'date':
return data.toString();
case 'object':
Expand Down