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

Method trimFront

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

* Remove `count` items from the head without returning them. * O(count) for GC cleanup.

(count)

Source from the content-addressed store, hash-verified

80 * O(count) for GC cleanup.
81 */
82 trimFront(count) {
83 if (count <= 0) return;
84 if (count >= this.#size) {
85 this.clear();
86 return;
87 }
88 for (let i = 0; i < count; i++) {
89 this.#backing[(this.#head + i) & this.#mask] = undefined;
90 }
91 this.#head = (this.#head + count) & this.#mask;
92 this.#size -= count;
93 }
94
95 /**
96 * Find the logical index of `item` (reference equality). O(n).

Callers 3

#tryTrimBufferMethod · 0.80
#tryTrimBufferMethod · 0.80
#tryTrimBufferMethod · 0.80

Calls 1

clearMethod · 0.95

Tested by

no test coverage detected