{"name":"ringbufferjs","version":"1.1.0","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","gitHead":"08310d5b03ec3184b08c3e6d4601b0ae63279f92","bugs":{"url":"https://github.com/janogonzalez/ringbufferjs/issues"},"homepage":"https://github.com/janogonzalez/ringbufferjs#readme","_id":"ringbufferjs@1.1.0","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"janogonzalez","email":"info@janogonzalez.com"},"maintainers":[{"name":"janogonzalez","email":"info@janogonzalez.com"}],"dist":{"integrity":"sha512-Hd1Z8xyaQLhdKtmbOuRCwCT9rKYk7SwUXENsA9pSAj6Jv4otUh7IwOlEhj0xu/xcP7hosMnmE7AYaVp6m8MCPQ==","shasum":"83f78108cf5dd95d2f3ab4a84352ad15829721d3","tarball":"http://registry-npm.ywwl.com/ringbufferjs/download/ringbufferjs-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHrbhOjXaGys25IqOlah2zFOHIMBGzEROybUPTfwBjt8AiEAnu7fm083altM+XW+tw/Ms+HbxkUnjp4X9QYJwM/tS9o="}],"size":2035,"noattachment":false,"key":"/ringbufferjs/-/ringbufferjs-1.1.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ringbufferjs-1.1.0.tgz_1505143934522_0.6105553477536887"},"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":1505143935426,"_cnpm_publish_time":1505143935426,"dist-tags":{"latest":"2.0.0"}}