{"id":22414936,"url":"https://github.com/phil-r/q","last_synced_at":"2025-08-01T00:31:55.804Z","repository":{"id":62421463,"uuid":"264947242","full_name":"phil-r/q","owner":"phil-r","description":"Simple queue task runner written in typescript","archived":false,"fork":false,"pushed_at":"2020-09-14T11:15:40.000Z","size":14,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-20T03:19:53.791Z","etag":null,"topics":["deno","queue","ts","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/phil-r.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":"2020-05-18T13:26:17.000Z","updated_at":"2023-06-02T22:01:57.000Z","dependencies_parsed_at":"2022-11-01T17:31:34.692Z","dependency_job_id":null,"html_url":"https://github.com/phil-r/q","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-r%2Fq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-r%2Fq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-r%2Fq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phil-r%2Fq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phil-r","download_url":"https://codeload.github.com/phil-r/q/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228321331,"owners_count":17901604,"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":["deno","queue","ts","typescript"],"created_at":"2024-12-05T15:10:06.332Z","updated_at":"2024-12-05T15:10:07.612Z","avatar_url":"https://github.com/phil-r.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Q\n\n[![CI](https://github.com/phil-r/q/workflows/CI/badge.svg)](https://github.com/phil-r/q/actions?query=workflow%3ACI)\n\n\u003e Simple queue task runner written in typescript\n\n## Usage\n\n```ts\nimport { queue } from 'https://deno.land/x/q/mod.ts';\n\nlet result = 0;\nconst task = (a: number) =\u003e (result += a);\nconst q = queue(task, 2); // 2 is concurrency\n\nq.drain(() =\u003e {\n  console.log(`Result: ${result}`);\n}); // will log `Result: 6`\n\nq.push(1);\nq.push([2, 3]);\n```\n\nor using async/await\n\n```ts\nimport { queue } from 'https://deno.land/x/q/mod.ts';\n\nlet result = 0;\nconst task = (a: number) =\u003e (result += a);\nconst q = queue(task, 2); // 2 is concurrency\n\nq.push(1);\nq.push([2, 3]);\n\nawait q.drain();\nconsole.log(`Result: ${result}`); // will log `Result: 6`\n```\n\nit's also possible to use `onDone` and `onError` callbacks\n\n```ts\nimport { queue } from 'https://deno.land/x/q/mod.ts';\n\nlet result = 0;\nconst task = (a: number) =\u003e {\n  if (a === 4) throw Error('ow no');\n  return (result += a);\n};\nconst q = queue(task, 2); // 2 is concurrency\n\nq.push([1, 2, 3, 4]);\n\nq.onDone((task, result) =\u003e\n  console.log(`For task: ${task}, result is ${result}`)\n);\n\n/* \nWill log:\nFor task: 1, result is 1\nFor task: 2, result is 3\nFor task: 3, result is 6\n*/\n\nq.onError((task, error) =\u003e console.error(`Task: ${task} failed with ${error}`));\n// Will log: Task: 4 failed with Error: ow no\n\nawait q.drain();\nconsole.log(`Result: ${result}`); // will log `Result: 6`\n```\n\n## Run tests\n\n```\ndeno test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphil-r%2Fq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphil-r%2Fq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphil-r%2Fq/lists"}