{"name":"ringbufferjs","version":"1.0.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":"3e30ff2f72642669b5df3e5cef10b7df10af10c5","bugs":{"url":"https://github.com/janogonzalez/ringbufferjs/issues"},"homepage":"https://github.com/janogonzalez/ringbufferjs#readme","_id":"ringbufferjs@1.0.0","_shasum":"793e795c81f2fe2b1fa441af270f51a065f3be8b","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"janogonzalez","email":"info@janogonzalez.com"},"maintainers":[{"name":"janogonzalez","email":"info@janogonzalez.com"}],"dist":{"shasum":"793e795c81f2fe2b1fa441af270f51a065f3be8b","tarball":"http://registry-npm.ywwl.com/ringbufferjs/download/ringbufferjs-1.0.0.tgz","integrity":"sha512-gJ9AqqrIXDCMp3pXD9zqnDhlt0ExxQNJvol10iixnVjwdv0Rksve1wP6/qkyzlPkCcEoFPAdl9AIxzT2BB9PHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKe6D98DJGa1UStxPhlAMiMDbR2aZQ+MdzlyVwi14wfgIgcUbSuUN2QD9yEHOCIvIUZsiX5xsWGe9JwnKT/iqIm5Q="}],"size":2691,"noattachment":false,"key":"/ringbufferjs/-/ringbufferjs-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/ringbufferjs-1.0.0.tgz_1493902187011_0.7508348086848855"},"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":1493902188477,"_cnpm_publish_time":1493902188477,"dist-tags":{"latest":"2.0.0"}}