{"id":23447244,"url":"https://github.com/grofers/ccq","last_synced_at":"2025-07-13T12:41:58.751Z","repository":{"id":57195361,"uuid":"122189714","full_name":"grofers/ccq","owner":"grofers","description":"Javascript queues with concurrency control!","archived":false,"fork":false,"pushed_at":"2018-02-21T09:34:44.000Z","size":25,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-06-18T12:03:02.841Z","etag":null,"topics":["async","asynchronous","concurrency","javascript","queues"],"latest_commit_sha":null,"homepage":"https://bl.ocks.org/cdax/2d694bcef87643fdee747734c4d97b1b","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/grofers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-20T11:29:14.000Z","updated_at":"2023-08-16T09:54:58.000Z","dependencies_parsed_at":"2022-09-16T10:50:35.713Z","dependency_job_id":null,"html_url":"https://github.com/grofers/ccq","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/grofers/ccq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grofers%2Fccq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grofers%2Fccq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grofers%2Fccq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grofers%2Fccq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grofers","download_url":"https://codeload.github.com/grofers/ccq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grofers%2Fccq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265141439,"owners_count":23717756,"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":["async","asynchronous","concurrency","javascript","queues"],"created_at":"2024-12-23T21:16:54.637Z","updated_at":"2025-07-13T12:41:58.708Z","avatar_url":"https://github.com/grofers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ccq\n\n[![Build Status](https://travis-ci.org/grofers/ccq.svg?branch=master)](https://travis-ci.org/grofers/ccq)\n\n**Javascript queues with concurrency control!**\n\nYou can think of a controlled-concurrency queue as an array of tasks with a positive concurrency *n*, which means that at any given time, at most *n* of the queued tasks are being executed concurrently, while the rest are either waiting to commence execution, or have finished executing.\n\n## Installation\n\nIf you use NPM, use `npm install ccq`. Otherwise, download the latest release. AMD, CommonJS, and vanilla environments are supported. In vanilla, a `Queue` global is exported:\n\n```html\n\u003cscript src=\"https://github.com/grofers/ccq/releases/download/v0.1.0/ccq-0.1.0.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    var queue = new Queue();\n\u003c/script\u003e\n```\n\n[Try **ccq** in your browser](https://npm.runkit.com/ccq) or take a look at the demo at [https://bl.ocks.org/cdax/2d694bcef87643fdee747734c4d97b1b](https://bl.ocks.org/cdax/2d694bcef87643fdee747734c4d97b1b)\n\n## The Queue API\n\n#### `var queue = new Queue(n);`\n\nThis constructor function creates a new queue with a concurrency of `n`. You may add as many tasks to the queue as needed, but no more than `n` of these tasks are allowed to execute concurrently at any given time. If no `n` is passed, we get a queue with unbounded concurrency.\n\n```javascript\nvar Queue = require(\"ccq\").Queue;\n\n// creates a new queue with a concurrency of 5\nvar q = new Queue(5);\n```\n\n\n#### `queue.add(task[, taskArgs...]);`\n\nThe `add()` method adds a new task to the queue. At this point, if the queue concurrency hasn't been reached, then `task` is invoked immediately with the arguments `taskArgs`. Otherwise, `task` is added to a list of tasks already waiting to be executed. Therefore, once a task has been added to the queue, it may exist in one of 3 mutually exclusive states at any given time: **ACTIVE**, **WAITING** or **COMPLETED**.\n\nEach task is also passed a `callback(error, results)` function as its last argument. The task **must** call this function once it has finished executing, to inform the queue of its completion. In case of a successfull completion, the `error` argument passed to the `callback` **must** be `null`, and the `results` argument must contain a single value containing the result of the function execution.\n\n```javascript\n// adds a new `uploadFile` task to the queue\nqueue.add(uploadFile, files[i]);\n```\n\n#### `queue.await(callback);`\n\nFinally, the `await()` method can be used to tell the queue that no further tasks will be added to it, and that the `callback` function must be invoked once all the tasks have finished executing. This callback will be invoked with a list (`results`) of exceptions or return values from every task. The elements in `results` will match the order in which their corresponding tasks were added to the queue. For exceptions, the `isError` flag of the `result` element will be set. Result data (exception or return value) is available in `result.data`.\n\n```javascript\n// the callback passed to `.await()` will be invoked once all the tasks have finished\nqueue.await(function(results) {\n    var failedUploads = results.filter(function (result) { return result.isError; });\n    console.log(\n        'Finished uploading. '\n        + (results.length - failedUploads.length) + ' successful, '\n        + failedUploads.length + ' failed.'\n    );\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrofers%2Fccq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrofers%2Fccq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrofers%2Fccq/lists"}