{"id":19589776,"url":"https://github.com/supercharge/queue-datastructure","last_synced_at":"2025-04-27T12:33:06.559Z","repository":{"id":57163599,"uuid":"195229448","full_name":"supercharge/queue-datastructure","owner":"supercharge","description":"A queue data structure for Node.js","archived":false,"fork":false,"pushed_at":"2023-11-06T04:17:13.000Z","size":87,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T00:25:41.309Z","etag":null,"topics":["data-structure","data-structures","datastructure","nodejs","queue","supercharge"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/supercharge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-04T11:31:10.000Z","updated_at":"2023-11-06T04:15:27.000Z","dependencies_parsed_at":"2023-11-06T05:25:38.397Z","dependency_job_id":"571df992-5040-42b2-bdbd-c0fc5f00362c","html_url":"https://github.com/supercharge/queue-datastructure","commit_stats":{"total_commits":106,"total_committers":3,"mean_commits":"35.333333333333336","dds":0.2924528301886793,"last_synced_commit":"29e8f93d1fe177cd20982c1baeccdf7d29e2365d"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fqueue-datastructure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fqueue-datastructure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fqueue-datastructure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/supercharge%2Fqueue-datastructure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/supercharge","download_url":"https://codeload.github.com/supercharge/queue-datastructure/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251138934,"owners_count":21541976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structure","data-structures","datastructure","nodejs","queue","supercharge"],"created_at":"2024-11-11T08:20:45.217Z","updated_at":"2025-04-27T12:33:06.241Z","avatar_url":"https://github.com/supercharge.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\r\n  \u003ca href=\"https://superchargejs.com\"\u003e\r\n    \u003cimg width=\"471\" style=\"max-width:100%;\" src=\"https://superchargejs.com/images/supercharge-text.svg\" /\u003e\r\n  \u003c/a\u003e\r\n  \u003cbr/\u003e\r\n  \u003cbr/\u003e\r\n  \u003cp\u003e\r\n    \u003ch3\u003eQueue Datastructure\u003c/h3\u003e\r\n  \u003c/p\u003e\r\n  \u003cp\u003e\r\n    A queue data structure for Node.js and JavaScript.\r\n  \u003c/p\u003e\r\n  \u003cbr/\u003e\r\n  \u003cp\u003e\r\n    \u003ca href=\"#installation\"\u003e\u003cstrong\u003eInstallation\u003c/strong\u003e\u003c/a\u003e ·\r\n    \u003ca href=\"#usage\"\u003e\u003cstrong\u003eUsage\u003c/strong\u003e\u003c/a\u003e ·\r\n    \u003ca href=\"#api\"\u003e\u003cstrong\u003eAPI\u003c/strong\u003e\u003c/a\u003e\r\n  \u003c/p\u003e\r\n  \u003cbr/\u003e\r\n  \u003cbr/\u003e\r\n  \u003cp\u003e\r\n    \u003ca href=\"https://www.npmjs.com/package/@supercharge/queue-datastructure\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@supercharge/queue-datastructure.svg\" alt=\"Latest Version\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://www.npmjs.com/package/@supercharge/queue-datastructure\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@supercharge/queue-datastructure.svg\" alt=\"Monthly downloads\"\u003e\u003c/a\u003e\r\n  \u003c/p\u003e\r\n  \u003cp\u003e\r\n    \u003cem\u003eFollow \u003ca href=\"http://twitter.com/marcuspoehls\"\u003e@marcuspoehls\u003c/a\u003e and \u003ca href=\"http://twitter.com/superchargejs\"\u003e@superchargejs\u003c/a\u003e for updates!\u003c/em\u003e\r\n  \u003c/p\u003e\r\n\u003c/div\u003e\r\n\r\n---\r\n\r\n## Installation\r\n\r\n```\r\nnpm i @supercharge/queue-datastructure\r\n```\r\n\r\n\r\n## Notice\r\nThis package is ESM-only.\r\n\r\n\r\n## Usage\r\nUsing the queue data structure is pretty straightforward. The library exposes a `Queue` class that you can use to create a queue instance. You can create a queue from existing data or an empty one:\r\n\r\n```js\r\nimport { Queue } from '@supercharge/queue-datastructure'\r\n\r\n// create a queue from an existing array\r\nconst queue = new Queue([ 1, 2, 3 ])\r\n\r\n// or, create a queue from individual items\r\nconst queue = new Queue(1, 2, 3)\r\n\r\n// or, create an empty queue\r\nconst queue = new Queue()\r\n```\r\n\r\n\r\n## API\r\n\r\n#### `.enqueue(items)`\r\nPush new `items` to the end of the queue.\r\n\r\n```js\r\nqueue\r\n  .enqueue(1)\r\n  .enqueue(2, 3)\r\n  .enqueue([ 4, 5, 6])\r\n\r\n// Queue: 1, 2, 3, 4, 5, 6\r\n```\r\n\r\n\r\n#### `.dequeue()`\r\nRemove and return the item which is up for processing. Returns `undefined` if the queue is empty.\r\n\r\n```js\r\nqueue.enqueue(1, 2, 3)\r\nqueue.size() // 3\r\n\r\nqueue.dequeue() // 1\r\nqueue.size() // 2\r\n```\r\n\r\n\r\n#### `.peek()`\r\nReturns the first item without removing it from the queue. Returns `undefined` if the queue is empty.\r\n\r\n```js\r\nqueue.enqueue(1, 2, 3)\r\nqueue.peek() // 1\r\n```\r\n\r\n\r\n#### `.size()`\r\nReturns the number of items in the queue.\r\n\r\n```js\r\nqueue.size() // 0\r\nqueue.enqueue(1, 2)\r\nqueue.size() // 2\r\n```\r\n\r\n\r\n#### `.isEmpty()`\r\nReturns `true` if there are no items in the queue, `false` otherwise.\r\n\r\n```js\r\nqueue.isEmpty() // true\r\nqueue.enqueue(1)\r\nqueue.isEmpty() // false\r\n```\r\n\r\n\r\n#### `.isNotEmpty()`\r\nReturns `true` if there are items in the queue, `false` when the queue is empty.\r\n\r\n```js\r\nqueue.isNotEmpty() // false\r\nqueue.enqueue(1)\r\nqueue.isNotEmpty() // true\r\n```\r\n\r\n\r\n#### `.clear()`\r\nRemoves all items from the queue.\r\n\r\n```js\r\nqueue.clear()\r\nqueue.size() // 0\r\n```\r\n\r\n\r\n## Contributing\r\n\r\n1.  Create a fork\r\n2.  Create your feature branch: `git checkout -b my-feature`\r\n3.  Commit your changes: `git commit -am 'Add some feature'`\r\n4.  Push to the branch: `git push origin my-new-feature`\r\n5.  Submit a pull request 🚀\r\n\r\n\r\n## License\r\nMIT © [Supercharge](https://superchargejs.com)\r\n\r\n---\r\n\r\n\u003e [superchargejs.com](https://superchargejs.com) \u0026nbsp;\u0026middot;\u0026nbsp;\r\n\u003e GitHub [@supercharge](https://github.com/supercharge) \u0026nbsp;\u0026middot;\u0026nbsp;\r\n\u003e Twitter [@superchargejs](https://twitter.com/superchargejs)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupercharge%2Fqueue-datastructure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsupercharge%2Fqueue-datastructure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupercharge%2Fqueue-datastructure/lists"}