{"name":"ringbufferjs","version":"2.0.0","description":"a simple ring buffer data structure","keywords":["ring","buffer","circular","queue","ring buffer","circular buffer","data structure"],"homepage":"https://github.com/janogonzalez/ringbufferjs","bugs":{"url":"https://github.com/janogonzalez/ringbufferjs/issues"},"license":"MIT","author":{"name":"Jano González","email":"info@janogonzalez.com","url":"http://janogonzalez.com"},"main":"index.js","repository":{"type":"git","url":"git://github.com/janogonzalez/ringbufferjs.git"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"*","expect.js":"*"},"gitHead":"388be6a76f55635a14fadeb22c6d02db03e94117","_id":"ringbufferjs@2.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.14.5","dist":{"integrity":"sha512-GCOqTzUsTHF7nrqcgtNGAFotXztLgiePpIDpyWZ7R5I02tmfJWV+/yuJc//Hlsd8G+WzI1t/dc2y/w2imDZdog==","shasum":"09f40e2675a99cfef430b7ec5815ac1bc2e24120","tarball":"http://registry-npm.ywwl.com/ringbufferjs/download/ringbufferjs-2.0.0.tgz","fileCount":6,"unpackedSize":12583,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJetF1OCRA9TVsSAnZWagAADvkP/2V9NaTqR8I45gFA0SF/\nsyc8/3vb2mNJ+Hjx8YPwYtgr/wEsXN44RbDF5Ypo46y3/+nBidIcwtdzBqEz\noUQjgAI9WNQrPa8CJCKcBZ+yRT4Uzdh+Mnbc3mGgK9DMCJ90uRKDJLK5gvj+\nM8zLLVYuRsZvfbgNAl/qzwSZaLmLwEdsO4gtmzXNlgIhkOdFLYsT5eCAeYNa\nq2v9grLSS3s3gFVzDdz1sEdQ+9ZcRtMEWSXXayMWUgj1VGVJMNYp7l+/4g2x\nlQN8foFE+GG1XlhKfX7MRs1Hrxl04Cb/Xt9kFDnffGZ3IkeJmywgNMeiHDzc\nTa6Ste1iKXNDlZ4LFLrZUlPplapJDMmCDWxULiXU5T7Bcnjghn3PA1JDqDfF\nmEUfCPocy1mAMfEGnohbOrb8DxHZvwewnkCx6O9EzyHfH7U0ZJaE8HsN4cWI\nkTv6i2wyWT5bF+htI7znag46d1RFyVC8B057Uu2OJFqfwZZGjeUon/98Np92\nU53dKRywJAhs54mzlu0MBPOJm1llJSelrD/wYNhoMVnUmpR4XF6NsUEjqMgC\n3vc3z3lJp+eZYEsBdmWBK9RCaqYtwQS8hLos+82SmnZiZfxWYpd5HzGaPFP7\n256NysNDF36q7sffvdHQA8B7gxjskZ8Mwx6BAKld38xYfZepQ4WY0RFEDVyo\nmOV8\r\n=61h4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE9CQoPlPgpiRfbEI9t/f3j14mQlikpjs/vbVtgx3sK+AiEAgwj04uthiZrAwqrJlKsvF0QWeOt5nURTDytRv/Uo92g="}],"size":2829,"noattachment":false,"key":"/ringbufferjs/-/ringbufferjs-2.0.0.tgz"},"maintainers":[{"name":"janogonzalez","email":"info@janogonzalez.com"}],"_npmUser":{"name":"janogonzalez","email":"info@janogonzalez.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ringbufferjs_2.0.0_1588878669620_0.11012816506947476"},"_hasShrinkwrap":false,"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":1588878669728,"_cnpm_publish_time":1588878669728,"dist-tags":{"latest":"2.0.0"}}