{"name":"ringbufferjs","version":"0.0.1","description":"a simple ring buffer data structure","author":{"name":"Jano González","email":"info@janogonzalez.com"},"devDependencies":{"mocha":"*","expect.js":"*"},"main":"index.js","dependencies":{},"scripts":{"test":"mocha"},"repository":{"type":"git","url":"git://github.com/janogonzalez/ringbufferjs.git"},"keywords":["ring","buffer","circular","queue","ring buffer","circular buffer","data structure"],"license":"MIT","_id":"ringbufferjs@0.0.1","dist":{"shasum":"e9a6ad5323fcd8607f8aaba8c1c469916b9bcd55","tarball":"http://registry-npm.ywwl.com/ringbufferjs/download/ringbufferjs-0.0.1.tgz","integrity":"sha512-YlhudkckZ4yix71gy0ql/tSe+xXHMowroJr6bHaG7VbC2olQnnmyCHsSHShsT+UwyqJ69UOs0q3se5X3hsHeGA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICrNI4/ttLS/O0FiDuNKQ9jBaAC3UeAvrFGX6FLwYKBVAiBbzg/ZPxG/O8p6J3UUDTetY9OW/HL2RaHmosdrI5/aWg=="}],"size":2565,"noattachment":false,"key":"/ringbufferjs/-/ringbufferjs-0.0.1.tgz"},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"janogonzalez","email":"info@janogonzalez.com"},"maintainers":[{"name":"janogonzalez","email":"info@janogonzalez.com"}],"directories":{},"readme":"# ringbuffer.js\n\n[![Build Status](https://travis-ci.com/janogonzalez/ringbufferjs.svg?branch=master)](\n  https://travis-ci.com/janogonzalez/ringbufferjs)\n\nA simple ring buffer data structure for Node.js.\n\n## Installation\n\n```\n$ npm install ringbufferjs\n```\n\n## Example\n\n```js\nvar RingBuffer = require('ringbufferjs');\n\nvar ring = new RingBuffer(2);\n\nring.enq(10);\nring.enq(5);\nring.enq(1); // 10 will be discarded\nring.size(); // 2\nring.peek(); // 5\nring.deq(); // 5\nring.size(); // 1\n```\n\n## API\n\n### `RingBuffer()`\n\nInitializes a new empty `RingBuffer` with the default capacity (50).\n\n### `RingBuffer(capacity)`\n\nInitializes a new empty `RingBuffer` with the given `capacity`.\n\n### `RingBuffer(capacity, evictedCb)`\n\nInitializes a new empty `RingBuffer` with the given `capacity` which will\nexecute the provided `evictedCb` when an element is evicted.\n\n### `RingBuffer#capacity()`\n\nReturns the capacity of the ring buffer.\n\n### `RingBuffer#deq()`\n\nDequeues the top element of the ring buffer.\nThrows an `Error` when the buffer is empty.\n\n### `RingBuffer#deqN(count)`\n\nDequeues `count` elements from the top of the ring buffer and returns them.\nThrows an `Error` if there are not enough elements in the buffer.\n\n### `RingBuffer#enq(element)`\n\nEnqueues the `element` at the end of the ring buffer and returns its new size.\nWhen the buffer is full the oldest element is discarded.\n\n### `RingBuffer#isEmpty()`\n\nReturns whether the ring buffer is empty or not.\n\n### `RingBuffer#isFull()`\n\nReturns whether the ring buffer is full or not.\n\n### `RingBuffer#peek()`\n\nPeeks at the top element of the ring buffer.\nThrows an `Error` when the buffer is empty.\n\n### `RingBuffer#peekN(count)`\n\nReturns `count` elements from the top of the ring buffer.\nThrows an `Error` if there are not enough elements in the buffer.\n\n### `RingBuffer#size()`\n\nReturns the size of the ring buffer.\n\n## Testing\n\n```\n$ npm install\n$ npm test\n```\n\n## Licence\n\nMIT\n","publish_time":1362434023841,"_cnpm_publish_time":1362434023841,"dist-tags":{"latest":"2.0.0"}}