MCPcopy Index your code
hub / github.com/nodejs/node / ConsArray

Class ConsArray

deps/v8/tools/consarray.mjs:39–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 * @constructor
38 */
39export class ConsArray {
40 constructor() {
41 this.tail_ = new ConsArrayCell(null, null);
42 this.currCell_ = this.tail_;
43 this.currCellPos_ = 0;
44 }
45 /**
46 * Concatenates another array for iterating. Empty arrays are ignored.
47 * This operation can be safely performed during ongoing ConsArray
48 * iteration.
49 *
50 * @param {Array} arr Array to concatenate.
51 */
52 concat(arr) {
53 if (arr.length > 0) {
54 this.tail_.data = arr;
55 this.tail_ = this.tail_.next = new ConsArrayCell(null, null);
56 }
57 }
58
59 /**
60 * Whether the end of iteration is reached.
61 */
62 atEnd() {
63 return this.currCell_ === null ||
64 this.currCell_.data === null ||
65 this.currCellPos_ >= this.currCell_.data.length;
66 }
67
68 /**
69 * Returns the current item, moves to the next one.
70 */
71 next() {
72 const result = this.currCell_.data[this.currCellPos_++];
73 if (this.currCellPos_ >= this.currCell_.data.length) {
74 this.currCell_ = this.currCell_.next;
75 this.currCellPos_ = 0;
76 }
77 return result;
78 }
79}
80
81
82/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…