项目作者: rjz

项目描述 :
A lightweight circular queue for node.js
高级语言: JavaScript
项目地址: git://github.com/rjz/circular-queue.git
创建时间: 2015-06-27T21:26:34Z
项目社区:https://github.com/rjz/circular-queue

开源协议:Other

下载


CircularQueue

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

Build
Status

Installation

Clone this repository:

  1. $ npm install circular-queue

Now, instantiate a queue with a fixed maximum size:

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

offer it some items:

  1. queue.offer('one');
  2. queue.offer('two');
  3. queue.offer('three');

…and peek at or poll them from the queue:

  1. queue.peek(); // 'one'
  2. queue.poll(); // 'one'
  3. queue.peek(); // 'two'

Events

Instances of CircularQueue will emit:

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

Testing

Lint and run test suite:

  1. $ npm test

License

MIT