Skip to content

adellamaggiora/circular-buffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

Easy to use and high performance circular buffer

Resources

License

Stars

Watchers

Forks

Packages

No packages published