1.0.1 • Published 3 years ago

easy-circular-buffer v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.