From 0209f7b46954d1b7bf923b4191e5a356ec09622c Mon Sep 17 00:00:00 2001 From: Chen Su Date: Tue, 14 Nov 2023 03:13:20 +0800 Subject: fix(ext/console): fix inspecting iterators error. (#20720) Fixes #19776 and #20676. --- ext/node/polyfills/internal_binding/util.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ext/node/polyfills/internal_binding') diff --git a/ext/node/polyfills/internal_binding/util.ts b/ext/node/polyfills/internal_binding/util.ts index 38eeebee0..651fe9a4b 100644 --- a/ext/node/polyfills/internal_binding/util.ts +++ b/ext/node/polyfills/internal_binding/util.ts @@ -129,3 +129,18 @@ export function getOwnNonIndexProperties( } return result; } + +export function previewEntries( + iter: Iterable, + isKeyValue?: boolean, +): Array { + if (isKeyValue) { + const arr = [...iter]; + if (Array.isArray(arr[0]) && arr[0].length === 2) { + return [([] as unknown[]).concat(...arr), true]; + } + return [arr, false]; + } else { + return [...iter]; + } +} -- cgit v1.2.3