{"name":"yocto-queue","version":"0.1.0","keywords":["queue","data","structure","algorithm","queues","queuing","list","array","linkedlist","fifo","enqueue","dequeue","data-structure"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"yocto-queue@0.1.0","homepage":"https://github.com/sindresorhus/yocto-queue#readme","bugs":{"url":"https://github.com/sindresorhus/yocto-queue/issues"},"dist":{"shasum":"0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b","tarball":"http://registry-npm.ywwl.com/yocto-queue/download/yocto-queue-0.1.0.tgz","fileCount":5,"integrity":"sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==","signatures":[{"sig":"MEYCIQDT6PTeFAw+w2P0CanG3paScSDLRLBiZjcK25Jh2KvzfQIhAKTn5VxVaUWC1f0cOT5b/wdosBeinflqpF9rUUUuiekj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6027,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfvKKwCRA9TVsSAnZWagAAGXMP+gOOaFATY9WhVgSiN4ZI\nwyHaog6af9hieXnM+eZf3YLHnC5caM20SxdnHcvILsuf9K0pqkMXtzC9Ghgs\njnFaQ65BLvEwz7wByXB799QoCNv3YOoEKEwvqg81fTEJwVpPB7/1LD/phu2j\n3wcWbfyUBYQUHrFqZeb7eR1CnHDxov6odtBxLs84USK+0+8fLmO4wn30Quwl\nyVGrlNm3X4NmuJFetHLUhfFjIL3cBlfG191/DeNPPhqVBxx2Uj2l9oUX5eVW\nIVkL0s7OxQn8L8VN/YxOqus+kitnku2Jb4hVo/yUzZcx5w+KPMMNBnHqljNm\nGUbrfQBHtUJiZOB684vsR8TFAc6ZWrIAzXKtcejof/qEkGV/60iS63xANr2w\ntEYoNsAlDVBZYqXXbV7rwyBAIEM7SvrVsvGWMS8tAgnMUD0pf2TO1mOP7ph8\nWGlMuJegqEBg9HoHdXtfpQEIq8s76XGnROX1Y+OFXdHiWCYo2US9PsIMXRQ4\notOcWRV/DIXXmKn+pFM8CaE09NpIJBPLCeMtxHSR2qCCS4dCTx7kD09oFdF6\nMETv0Y0/5nPZjUMLsY2xBjp10ntpzH+4iTWmYYhBlNrcNpc/eoZIBMyS3+Ot\n3ZE7p9eNKNW6sdD/pQycDV0S1565FymQaOdB4RAUR26/zayYuZFlqva9hXWR\nMel2\r\n=rCXP\r\n-----END PGP SIGNATURE-----\r\n","size":2765,"noattachment":false,"key":"/yocto-queue/-/yocto-queue-0.1.0.tgz"},"engines":{"node":">=10"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"af91c37f51aecf607ca2261b907b9d86b6a69e77","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/yocto-queue.git","type":"git"},"_npmVersion":"6.14.9","description":"Tiny queue data structure","directories":{},"_nodeVersion":"10.22.1","_hasShrinkwrap":false,"devDependencies":{"xo":"^0.35.0","ava":"^2.4.0","tsd":"^0.13.1"},"_npmOperationalInternal":{"tmp":"tmp/yocto-queue_0.1.0_1606197935700_0.6375493777344527","host":"s3://npm-registry-packages"},"readme":"# yocto-queue [![](https://badgen.net/bundlephobia/minzip/yocto-queue)](https://bundlephobia.com/result?p=yocto-queue)\n\n> Tiny queue data structure\n\nYou should use this package instead of an array if you do a lot of `Array#push()` and `Array#shift()` on large arrays, since `Array#shift()` has [linear time complexity](https://medium.com/@ariel.salem1989/an-easy-to-use-guide-to-big-o-time-complexity-5dcf4be8a444#:~:text=O(N)%E2%80%94Linear%20Time) *O(n)* while `Queue#dequeue()` has [constant time complexity](https://medium.com/@ariel.salem1989/an-easy-to-use-guide-to-big-o-time-complexity-5dcf4be8a444#:~:text=O(1)%20%E2%80%94%20Constant%20Time) *O(1)*. That makes a huge difference for large arrays.\n\n> A [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) is an ordered list of elements where an element is inserted at the end of the queue and is removed from the front of the queue. A queue works based on the first-in, first-out ([FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics))) principle.\n\n## Install\n\n```sh\nnpm install yocto-queue\n```\n\n## Usage\n\n```js\nimport Queue from 'yocto-queue';\n\nconst queue = new Queue();\n\nqueue.enqueue('🦄');\nqueue.enqueue('🌈');\n\nconsole.log(queue.size);\n//=> 2\n\nconsole.log(...queue);\n//=> '🦄 🌈'\n\nconsole.log(queue.dequeue());\n//=> '🦄'\n\nconsole.log(queue.dequeue());\n//=> '🌈'\n```\n\n## API\n\n### `queue = new Queue()`\n\nThe instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop, or use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.\n\n#### `.enqueue(value)`\n\nAdd a value to the queue.\n\n#### `.dequeue()`\n\nRemove the next value in the queue.\n\nReturns the removed value or `undefined` if the queue is empty.\n\n#### `.peek()`\n\nGet the next value in the queue without removing it.\n\nReturns the value or `undefined` if the queue is empty.\n\n#### `.clear()`\n\nClear the queue.\n\n#### `.size`\n\nThe size of the queue.\n\n## Related\n\n- [quick-lru](https://github.com/sindresorhus/quick-lru) - Simple “Least Recently Used” (LRU) cache\n","publish_time":1606197935875,"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_cnpm_publish_time":1606197935875,"dist-tags":{"latest":"1.2.2"}}