Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

easy-circular-buffer

Easy to use and high performance circular buffer

circular, buffer, circular buffer, circularbuffer, ring, ring buffer, ringbuffer

readme

easy-circular-buffer

Easy to use and high performance circular buffer

Installation

npm i easy-circular-buffer

Usage

const { createCircularBuffer } = require('easy-circular-buffer')

const cb = createCircularBuffer(length)

Methods
  • cb.insert() <void> Insert item into circular buffer.
  • cb.peekNewest() <any> Returns the newest item inserted in the circular buffer.
  • cb.peekOldest() <any> Returns the oldest item inserted in the circular buffer.
  • cb.toArray() <Array<any>> Returns an array sorted from oldest (at index 0) to newest item.