circular-queue
A lightweight circular queue
Last updated 4 years ago by rjz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install circular-queue 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.0.2                                ...           latest (4 years ago)

3 Versions

  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
  • 0.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |