We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c6c39d4 commit 6b93fa8Copy full SHA for 6b93fa8
1 file changed
lib/internal/streams/iter/ringbuffer.js
@@ -65,9 +65,11 @@ class RingBuffer {
65
66
/**
67
* Read item at a logical index (0 = head). O(1).
68
+ * Returns undefined if index is out of bounds.
69
* @returns {any}
70
*/
71
get(index) {
72
+ if (index < 0 || index >= this.#size) return undefined;
73
return this.#backing[(this.#head + index) % this.#capacity];
74
}
75
0 commit comments