{"name":"grouped-queue","version":"2.1.0","description":"In memory queue system prioritizing tasks","types":"lib/queue.d.ts","main":"lib/queue.js","scripts":{"test":"mocha -R spec","lint":"npx oxlint && npx prettier --check ."},"repository":{"type":"git","url":"git+https://github.com/SBoudrias/grouped-queue.git"},"keywords":["queue","async","task","flow","control"],"author":{"name":"Simon Boudrias","email":"admin@simonboudrias.com"},"license":"MIT","engines":{"node":">=8.0.0"},"devDependencies":{"mocha":"^11.7.1","oxlint":"^1.12.0","prettier":"^3.6.2","sinon":"^21.0.0"},"gitHead":"10f41e77c2b5f976faa3bb803b29b4d0895ee19b","bugs":{"url":"https://github.com/SBoudrias/grouped-queue/issues"},"homepage":"https://github.com/SBoudrias/grouped-queue#readme","_id":"grouped-queue@2.1.0","_nodeVersion":"24.5.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-c5NDCWO0XiXuJAhOegMiNotkDmgORN+VNo3+YHMhWpoWG/u2+8im8byqsOe3/myI9YcC//plRdqGa2AE3Qsdjw==","shasum":"08a3063c9e4eafdd22455a2132487dbd8220debf","tarball":"http://registry-npm.ywwl.com/grouped-queue/download/grouped-queue-2.1.0.tgz","fileCount":5,"unpackedSize":9397,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDFrMieXfelbT7RkzgikrwHxdvVy7acadrWUIpccK8GVAiAbVcyQZvN+k5UNB2w9CjxgCJnFnDOWjI4VeDEEiYQqfA=="}],"size":3632,"noattachment":false,"key":"/grouped-queue/-/grouped-queue-2.1.0.tgz"},"_npmUser":{"name":"sboudrias","email":"admin@simonboudrias.com"},"directories":{},"maintainers":[{"name":"sboudrias","email":"admin@simonboudrias.com"},{"name":"mshima","email":"marceloshima@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/grouped-queue_2.1.0_1755446588787_0.20120154584787708"},"_hasShrinkwrap":false,"readme":"# Grouped Queue\n\nIn memory queue system prioritizing tasks.\n\n# Documentation\n\n## Installation\n\n```bash\nnpm install --save grouped-queue\n```\n\n## Methods\n\n### Constructor\n\nThe constructor takes an optional array of task groups. The first `String` name will be the first queue to be emptied, the second string will be the second group emptied, etc.\n\nBy default, the constructor will always add a `default` queue in the last position. You can overwrite the position of the `default` group if you specify it explicitly.\n\n```javascript\nimport Queue from \"grouped-queue\";\n\nconst queue = new Queue([\"first\", \"second\", \"third\"]);\n```\n\n### Queue#add `add( [group], task, [options] )`\n\nAdd a task into a group queue. If no group name is specified, `default` will be used.\n\nImplicitly, each time you add a task, the queue will start emptying (if not already running).\n\nEach task function is passed a callback function. This callback must be called when the task is complete.\n\n```javascript\nqueue.add((cb) => {\n  DB.fetch().then(cb);\n});\n```\n\n#### Option: `once`\n\nYou can register tasks in queues that will be dropped if they're already planned. This is done with the `once` option. You pass a String (basically a name) to the `once` option.\n\n```javascript\n// This one will eventually run\nqueue.add(method, { once: \"readDB\" });\n\n// This one will be dropped as `method` is currently in the queue\nqueue.add(method3, { once: \"readDB\" });\n```\n\n#### Option: `run`\n\nYou can register a task without launching the run loop by passing the argument `run: false`.\n\n```javascript\nqueue.add(method, { run: false });\n```\n\n### Delaying runs\n\nIf you don't want tasks to run as they're added, you can hold the queue until manually starting.\n\n```javascript\nconst queue = new Queue(\n  [\"first\", \"second\", \"third\"],\n  // `runOnAdd` option; this boolean instruct the queue to not auto-start.\n  false,\n);\n\n// Later on, to start processing\nqueue.start();\n\n// And pause to stop processing new tasks; running task will complete.\nqueue.pause();\n```\n\n## Events\n\n### `end`\n\nThis event is called **each time** the queue emptied itself.\n\n```javascript\nqueue.on(\"end\", () => {\n  console.log(\"done!\");\n});\n```\n\n# Contributing\n\n- **Unit test**: Unit tests are written in Mocha. Please add a unit test for every new feature\n  or bug fix. `npm test` to run the test suite.\n- **Documentation**: Add documentation for every API change. Feel free to send corrections\n  or better docs!\n- **Pull Requests**: Send _fixes_ PR on the `master` branch.\n\n# License\n\nCopyright (c) 2013 Simon Boudrias (twitter: @vaxilart)  \nLicensed under the MIT license.\n","publish_time":1755446588982,"_cnpm_publish_time":1755446588982,"dist-tags":{"latest":"2.1.0","next-2":"2.0.0-beta.2"}}