circular-queue

0.0.2 • Public • Published

CircularQueue

A lightweight circular queue, useful for situations where losing stale data is preferable to unchecked memory growth.

BuildStatus

Installation

Clone this repository:

$ npm install circular-queue

Now, instantiate a queue with a fixed maximum size:

var CircularQueue = require('circular-queue');
var queue = new CircularQueue(10);

...offer it some items:

queue.offer('one');
queue.offer('two');
queue.offer('three');

...and peek at or poll them from the queue:

queue.peek(); // 'one'
queue.poll(); // 'one'
queue.peek(); // 'two'

Events

Instances of CircularQueue will emit:

  • 'evict' - when stale items are evicted from the queue

Testing

Lint and run test suite:

$ npm test

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    2
  • 0.0.1
    1
  • 0.0.0
    1

Package Sidebar

Install

npm i circular-queue

Weekly Downloads

4

Version

0.0.2

License

MIT

Last publish

Collaborators

  • rjz