node/lib/internal/v8.js
Ben Noordhuis 05948d8e4e lib: remove use of Debug.MakeMirror()
This paves the way for removing `vm.runInDebugContext()`.  Inspection
of Map and Set iterators is now done through V8 instrinsics.

Fixes: https://github.com/nodejs/node/issues/11875
PR-URL: https://github.com/nodejs/node/pull/13295
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-11-24 00:13:44 +01:00

22 lines
380 B
JavaScript

'use strict';
function take(it, n) {
const result = [];
for (const e of it) {
if (--n < 0)
break;
result.push(e);
}
return result;
}
function previewMapIterator(it, n) {
return take(%MapIteratorClone(it), n);
}
function previewSetIterator(it, n) {
return take(%SetIteratorClone(it), n);
}
module.exports = { previewMapIterator, previewSetIterator };