MCPcopy Create free account
hub / github.com/nodejs/node / #grow

Method #grow

lib/internal/streams/iter/ringbuffer.js:139–148  ·  view source on GitHub ↗

* Double the backing capacity, linearizing the circular layout.

()

Source from the content-addressed store, hash-verified

137 * Double the backing capacity, linearizing the circular layout.
138 */
139 #grow() {
140 const newCapacity = (this.#mask + 1) * 2;
141 const newBacking = new Array(newCapacity);
142 for (let i = 0; i < this.#size; i++) {
143 newBacking[i] = this.#backing[(this.#head + i) & this.#mask];
144 }
145 this.#backing = newBacking;
146 this.#head = 0;
147 this.#mask = newCapacity - 1;
148 }
149}
150
151module.exports = { RingBuffer };

Callers 2

pushMethod · 0.95
unshiftMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected