{"_id":"@anthonyalbertyn/simple-queue","_rev":"1-a2227efc814247bfe6ba79196d6dc6c3","name":"@anthonyalbertyn/simple-queue","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@anthonyalbertyn/simple-queue","version":"1.0.0","description":"Queue data structure with enqueue, dequeue, peek, size and flush methods","main":"index.js","directories":{"lib":"lib"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1","example1":"node ./examples/example1.js","example2":"node ./examples/example2.js"},"repository":{"type":"git","url":"git+https://github.com/anthonyalbertyn/simple-queue.git"},"keywords":["simple","queue","enqueue","dequeue","node"],"author":{"name":"Anthony Albertyn"},"license":"MIT","bugs":{"url":"https://github.com/anthonyalbertyn/simple-queue/issues"},"homepage":"https://github.com/anthonyalbertyn/simple-queue#readme","gitHead":"2dd5c818832bfd7f18cab3db46267924264987e1","_id":"@anthonyalbertyn/simple-queue@1.0.0","_nodeVersion":"14.15.2","_npmVersion":"8.1.4","dist":{"integrity":"sha512-tgN7DHWgBz6WiGC82h+87bhtrv/u0AvXmhbRJHQXxIJsZ9WAk8Ix+5AALxk9uGUEqlNe+zhRx1bnvV7ZNoUUXg==","shasum":"0e156c32c6e896c49c21e2aeb15c34b4adc04c10","tarball":"https://registry.npmjs.org/@anthonyalbertyn/simple-queue/-/simple-queue-1.0.0.tgz","fileCount":9,"unpackedSize":7259,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiAMNQCRA9TVsSAnZWagAAacoP/RftR0SujoMVXFCsxuO8\nqkK08mDk3Yb2L1cnxzgvS08LSw4ykb1RD5j9efM8JzooSywwHDFoQl7HBYZn\nKiju9Tu3gpL/zIh3SUsFuop0XP3tkxApAyycYCSEErfkGd9pDTfAmya9WVr4\nyFLf+zdn5r9ZnDMQ7QHs03QyJffh3sxZ5SGbSCHWOGIZ/lVzZwUN0j6eT3di\nnitU64mj+byFlftGXBBY2IBAo8IxeNbw+/a7h3261lFdqSm7K1B4MlDKAeLb\nCxDLdLNf518EFBnJx1NgKK6ChCCDnSWX3Ol4g2hdVhSB52fNbaeirC5uJUc3\nOhuENcMIRKzd/vQkHNbRkRI1zjA58DQ/+XEaIVt16Md1QCAspWoAD1fWHRiE\n+9bTyoIYGgnyNC4MQu21UJTem1g1i0tPdQpV0l/8msjWzgnNfz+bZ+rLLmpo\nEFPhBv5Tjflbw2Rkx5rG3UmU9AsYP8o4kYQNIY1cKMYYSfU3+JqCSUcDaFKX\nu1TcBBn7e7A8JcCHC7jZrSgGPzXWFxU2OdTUcC1QYbsnphyjyyz8HCw6BFgf\nCxZ588IInmS/OBoirzVM6cqKtkqZmUkqI1pu4I53J/3UwAuSgWMnQy63EnHh\nflpnvkOp397InOhUHbNtfE3fsaz/bQs4KTjEoSxfciIGqRo9WhBOC7CmRUAl\nSuh6\r\n=WWCh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGNYBTwq3QPIOTD9nglTVraH06t4DeYBhXj2gPPXkunXAiEAqI6j46OYxPvd5kflHjzApEjFFYcLv9onj/9LacHIuhA="}]},"_npmUser":{"name":"anthonyalbertyn","email":"anthonyalbertyn@gmail.com"},"maintainers":[{"name":"anthonyalbertyn","email":"anthonyalbertyn@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-queue_1.0.0_1644217168423_0.41090826801693336"},"_hasShrinkwrap":false}},"time":{"created":"2022-02-07T06:59:28.322Z","1.0.0":"2022-02-07T06:59:28.634Z","modified":"2022-04-04T14:21:41.454Z"},"maintainers":[{"name":"anthonyalbertyn","email":"anthonyalbertyn@gmail.com"}],"description":"Queue data structure with enqueue, dequeue, peek, size and flush methods","homepage":"https://github.com/anthonyalbertyn/simple-queue#readme","keywords":["simple","queue","enqueue","dequeue","node"],"repository":{"type":"git","url":"git+https://github.com/anthonyalbertyn/simple-queue.git"},"author":{"name":"Anthony Albertyn"},"bugs":{"url":"https://github.com/anthonyalbertyn/simple-queue/issues"},"license":"MIT","readme":"# simple-queue\n\nSimpleQueue can be used in server-side Node or other JavaScript projects\n\nSimpleQueue is a simple queue data structure with enqueue, dequeue, peek, size and flush methods.\n\nMIT License, see LICENSE for more details\n\n## Uses case\n\nWhen you need a queue that has no dependencies on other libraries and you just want something lightweight that does the job. No bells and whistles and just works. Also when when you want to keep your code clean and DRY and get on with doing more interesting things :)\n\n## Getting started\n\n```\nnpm install @anthonyalbertyn/simple-queue\n```\n\n## Using simple-queue\n\n```\nconst SimpleQueue = require('@anthonyalbertyn/simple-queue');\n\nconst q = new SimpleQueue();\n\n```\n\nAdd an item to the queue\n\n``` q.enqueue(\"Hello\") ```\n\n``` q.enqueue(101) ```\n\nAdd multiple items to the queue at a time\n\n``` q.enqueue(1, 7, 24) ```\n\nRemove an item from the front of the queue\n\n``` const item = q.dequeue() ```\n\nCopying the item at the front of the queue, but not removing it from the queue\n\n``` const item = q.peek() ```\n\nFinding the length of the queue\n\n``` const length = q.size() ```\n\nFlushing the queue ie. deleting all the items\n\n``` q.flush() ```\n\n\nYou may create more than one SimpleQueue in your code.\n\n```\n    const q1 = new SimpleQueue();\n    const q2 = new SimpleQueue();\n\n```\n\n## Limitations\n\nThe actual queue under the hood is a JavaScript array and not a linked list. Adding items to the queue are constant time O(1), but removing an item from the queue has time complexity of O(n) as all the items in the array need to be moved one position to the left by JavaScript. SimpleQueue should work great for small to medium length queus, but as the length of the queue grows, the time to remove items will increase exponentially.\n\n## Non-scientific benchmark\n\nTime to add \"The quick brown fox jumps over the lazy dog\" to the queue 30,000 time: around 25 milliseconds\n\nTime to dequeue the above queue 30,000 times: around 365 milliseconds\n\nThese are just crude benchmarks and times can differ depending on where you are running the code and what else is happening in your app or system, and what data the queue contains, so no guarantees at all on performance.\n\nSee examples/example2 for details on how this was tested\n\n## Maintainers\n\nThere is currently only one maintainer, Anthony Albertyn, and the plan is to keep this module simple, lightweight and if possible resist adding more features unless there are good reasons to do so.\n","readmeFilename":"README.md"}