diff options
Diffstat (limited to 'ext/node/polyfills/internal_binding/util.ts')
-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]; + } +} |