summaryrefslogtreecommitdiff
path: root/lib/internal/v8.js
blob: b80e3de33d615536d2f8617e0ab2afd2c1432888 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'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 };