v1.0.4
Easy to use and high performance circular buffer
Repository
Current version released
5 years ago
circular_buffer
Easy to use and high performance circular buffer
Usage
import { CircularBuffer } from 'https://deno.land/x/circular_buffer@v1.0.4/mod.ts'
const cb = new CircularBuffer<T>(length)
API
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.cb.clear()<*void*> Clear the circular buffer.cb.capacity()<*number*> Returns the capacity (max size available) in the circular buffer.cb.size()<*number*> Returns the current size (total elements) of the circular buffer.cb.isFull()<*boolean*> Returns true if circular buffer is full, otherwise false.