easy-circular-buffer

Easy to use and high performance circular buffer

Usage no npm install needed!

<script type="module">
  import easyCircularBuffer from 'https://cdn.skypack.dev/easy-circular-buffer';
</script>

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.