mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 14:32:49 +00:00

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>
22 lines
380 B
JavaScript
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 };
|