{"id":16370243,"url":"https://github.com/delvedor/workq","last_synced_at":"2025-08-07T02:18:13.729Z","repository":{"id":57399312,"uuid":"107134122","full_name":"delvedor/workq","owner":"delvedor","description":"A super tiny work queue","archived":false,"fork":false,"pushed_at":"2019-11-30T14:38:27.000Z","size":23,"stargazers_count":37,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T12:33:32.815Z","etag":null,"topics":["jobs","queue","workflow"],"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/delvedor.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":"2017-10-16T13:52:20.000Z","updated_at":"2024-09-25T09:13:13.000Z","dependencies_parsed_at":"2022-09-01T18:21:34.924Z","dependency_job_id":null,"html_url":"https://github.com/delvedor/workq","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delvedor%2Fworkq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delvedor%2Fworkq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delvedor%2Fworkq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delvedor%2Fworkq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delvedor","download_url":"https://codeload.github.com/delvedor/workq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232802587,"owners_count":18578689,"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":["jobs","queue","workflow"],"created_at":"2024-10-11T03:04:25.724Z","updated_at":"2025-01-07T00:19:08.334Z","avatar_url":"https://github.com/delvedor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# workq\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://travis-ci.org/delvedor/workq.svg?branch=master)](https://travis-ci.org/delvedor/workq) [![Coverage Status](https://coveralls.io/repos/github/delvedor/workq/badge.svg?branch=master)](https://coveralls.io/github/delvedor/workq?branch=master)\n\nA super tiny work queue.\n\nIt can handle nested queues, the order of execution is guaranteed.  \nThe top level queue will start automatically once you add at least one job in the queue, the nested queues will start once the `done` callback has been called; you cannot add more jobs in the current queue after `done` has been called.\n\nIf you need a shared queue between multiple files pass the option `{ singleton: true }` in every file you need it.\n\n## Install\n```\nnpm i workq --save\n```\n## Usage\n```js\nconst q = require('workq')()\n\nq.add(job)\n\nfunction job (child, done) {\n  // perform some work\n  // you can add nested jobs!\n  child.add(nestedJob)\n  done()\n})\n\nfunction nestedJob (child, done) {\n  // perform some work\n  done()\n})\n```\n\nAsync/await and promises are supported as well!\n```js\nconst q = require('workq')()\n\nq.add(job)\n\n// there is no need to call `done`!\nasync function job (child) {\n  // perform some work\n  // you can add nested jobs!\n  child.add(nestedJob)\n})\n\nasync function nestedJob (child) {\n  // perform some work\n})\n```\n\nIf you need to know when a queue has finished all its jobs, you can use the `drain` api.  \n*Note that in the top queue the drain hook can be called multiple times.*\n```js\nconst q = require('workq')()\n\nq.drain(done =\u003e {\n  // the current queue has finished its jobs\n  // async await is supported as well\n  done()\n})\n\nq.add(job)\n\nfunction job (child, done) {\n  // perform some work\n  // you can add nested jobs!\n  child.add(nestedJob)\n  done()\n})\n\nfunction nestedJob (child, done) {\n  // perform some work\n  done()\n})\n```\n\nIf you need to pass some parameter to the job, just add them after the function in `add`:\n```js\nconst q = require('workq')()\n\nq.add(job, 'hello', 42)\n\nfunction job (child, greeting, num, done) {\n  console.log(greeting, num) // 'hello' 42\n  done()\n})\n```\n\nIf needed you can also use the `child` method to create custom child queues. The child queues will be executed once the current queue has finished its execution.\n```js\nconst q = require('workq')()\n\nconst childq = q.child()\n\nq.add(job, 'hello', 42)\nchildq.add(job, 'hello', 42)\n\nfunction job (child, greeting, num, done) {\n  console.log(greeting, num) // 'hello' 42\n  done()\n})\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelvedor%2Fworkq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelvedor%2Fworkq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelvedor%2Fworkq/lists"}