class CircularBuffer {

  constructor(length){
    this.buffer = new Int32Array(length);
    this.maxSize = length;
    this.currentSize = 0;
    this.openIndex = 0;
    this.lastFilledIndex = -1;
  }

  get(index){
    return this.buffer[(this.lastFilledIndex+index)%this.maxSize];
  }

  size(){
    return this.currentSize;
  }

  add(el){
    if (this.currentSize< this.maxSize) this.currentSize++;
    this.buffer[this.openIndex] = el;
    this.lastFilledIndex = (this.lastFilledIndex+1)%this.maxSize;
    this.openIndex = (this.lastFilledIndex + 1)%this.maxSize;
  }


}

module.exports = CircularBuffer;
@@ -567,16 +567,126 @@
 e;%0A  %7D%0A%0A
+  forEach(callback)%7B%0A    for (let i = 0; i %3C this.currentSize; i++) %7B%0A      callback(this.get(i));%0A    %7D%0A  %7D%0A%0A
 %0A%7D%0A%0Amodu

Add custom forEach function to Circular Buffer class