Skip to content

Commit

Permalink
simpler way to expand iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Jan 7, 2025
1 parent 7d39682 commit c756561
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/webgpu/print_environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ WPT disallows console.log and doesn't support logs on passing tests, so this doe
if (value === undefined || value === null) return null;
if (typeof value !== 'object') return value;
if (value instanceof Array) return value;
if (Symbol.iterator in value) return Array.from(value as Iterable<unknown>);

const valueObj = value as Record<string, unknown>;
return Object.fromEntries(
(function* () {
for (const key in valueObj) {
const value = valueObj[key];
if (value instanceof Object && Symbol.iterator in value) {
yield [key, Array.from(value as Iterable<unknown>)];
} else {
yield [key, value];
}
yield [key, valueObj[key]];
}
})()
);
Expand Down

0 comments on commit c756561

Please sign in to comment.