MCPcopy
hub / github.com/zloirock/core-js / createIterator

Function createIterator

tests/helpers/helpers.js:10–24  ·  view source on GitHub ↗
(elements, methods)

Source from the content-addressed store, hash-verified

8}
9
10export function createIterator(elements, methods) {
11 let index = 0;
12 const iterator = {
13 called: false,
14 next() {
15 iterator.called = true;
16 return {
17 value: elements[index++],
18 done: index > elements.length,
19 };
20 },
21 };
22 if (methods) for (const key in methods) iterator[key] = methods[key];
23 return iterator;
24}
25
26export function createSetLike(elements) {
27 return {

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…