diff options
author | Chen Su <ghosind@gmail.com> | 2023-11-14 03:13:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-13 20:13:20 +0100 |
commit | 0209f7b46954d1b7bf923b4191e5a356ec09622c (patch) | |
tree | 9d7ade1586ac741a34442d9ebb673e1b42bce679 /ext/node/polyfills/internal_binding | |
parent | fe0d9e078f49c6c69d5b3a02044b8709eb302b68 (diff) |
fix(ext/console): fix inspecting iterators error. (#20720)
Fixes #19776 and #20676.
Diffstat (limited to 'ext/node/polyfills/internal_binding')
-rw-r--r-- | ext/node/polyfills/internal_binding/util.ts | 15 |
1 files changed, 15 insertions, 0 deletions
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<unknown>, + isKeyValue?: boolean, +): Array<unknown | boolean> { + 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]; + } +} |