From c7565615c63f80129c4c79b8ada1334c59f94407 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Tue, 7 Jan 2025 11:51:05 -0800 Subject: [PATCH] simpler way to expand iterables --- src/webgpu/print_environment.spec.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/webgpu/print_environment.spec.ts b/src/webgpu/print_environment.spec.ts index 3207ef00549..3a4ab16b1f3 100644 --- a/src/webgpu/print_environment.spec.ts +++ b/src/webgpu/print_environment.spec.ts @@ -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); const valueObj = value as Record; 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)]; - } else { - yield [key, value]; - } + yield [key, valueObj[key]]; } })() );