{"id":46818,"library":"workq","title":"workq","description":"A super tiny work queue for Node.js (v3.0.0, stable). It guarantees ordered execution, supports nested queues, and runs automatically when jobs are added. Works with async/await and promises. Features a drain hook for completion and optional singletons for shared queues across files. Current version requires Node >=10. Lightweight alternative to async.queue or bull with minimal API surface.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/delvedor/workq","tags":["javascript","queue","work","q","nested","order","async"],"install":[{"cmd":"npm install workq","lang":"bash","label":"npm"},{"cmd":"yarn add workq","lang":"bash","label":"yarn"},{"cmd":"pnpm add workq","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is a factory function that returns a queue instance. ESM-only since v3.","wrong":"const { workq } = require('workq')","symbol":"workq","correct":"import workq from 'workq'"},{"note":"CommonJS require still works but is deprecated. Prefer ESM import.","wrong":"const { default: workq } = require('workq')","symbol":"workq (CommonJS)","correct":"const workq = require('workq')"},{"note":"workq is a factory, not a constructor. Call it as a function to create a queue.","wrong":"new workq()","symbol":"Queue instance methods","correct":"const q = workq(); q.add(job); q.drain(cb); q.child()"}],"quickstart":{"code":"import workq from 'workq';\n\nconst q = workq();\n\nq.add((child, done) => {\n  console.log('First job');\n  child.add((child2, done2) => {\n    console.log('Nested job');\n    done2();\n  });\n  done();\n});\n\nq.add(async (child) => {\n  console.log('Second job (async)');\n  await someAsyncWork();\n  // no need to call done\n});\n\nq.drain(() => {\n  console.log('All jobs finished');\n});\n\nasync function someAsyncWork() {\n  return new Promise(resolve => setTimeout(resolve, 100));\n}","lang":"javascript","description":"Shows creating a queue, adding jobs with callbacks (including nested), async/await, and drain hook."},"warnings":[{"fix":"Use import instead of require(), or downgrade to v2.x if you must use CommonJS.","message":"ESM-only since v3: Module not found, require() of ES Module not supported.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Switch to ESM import: import workq from 'workq'.","message":"CommonJS require() via const workq = require('workq') still works but may be removed in future.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Only call done() when you are finished adding child jobs. Use child queues if needed.","message":"Calling done() prevents adding more jobs to the current queue. Attempting to add after done will throw.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Make sure drain callback is idempotent or guard against multiple invocations.","message":"Drain hook can be called multiple times on the top-level queue if new jobs are added after drain.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'10':48 'across':42 'ad':24 'altern':50 'api':57 'async':65 'async.queue':52 'async/await':27 'automat':20 'bull':54 'complet':35 'current':44 'drain':32 'execut':14 'featur':30 'file':43 'guarante':12 'hook':33 'javascript':59 'job':22 'lightweight':49 'minim':56 'nest':16,63 'node':47 'node.js':8 'option':37 'order':13,64 'promis':29 'q':62 'queue':6,17,41,60 'requir':46 'run':19 'share':40 'singleton':38 'stabl':10 'super':3 'support':15 'surfac':58 'tini':4 'v3.0.0':9 'version':45 'work':5,25,61 'workq':1","created_at":"2026-06-07T13:01:46.639255+00:00","updated_at":"2026-06-07T13:01:46.639255+00:00","problems":[{"fix":"Use `const workq = require('workq')` for CommonJS or switch to ESM: `import workq from 'workq'`.","cause":"Using default import with CommonJS require incorrectly.","error":"TypeError: workq is not a function"},{"fix":"Use `import workq from 'workq'` or downgrade to v2.x.","cause":"Using require() with v3+ which is ESM-only.","error":"ERR_REQUIRE_ESM: require() of ES Module"},{"fix":"Ensure all jobs are added before calling done(), or use child queues for additional nested jobs.","cause":"Calling q.add() or child.add() after done() has been called for that queue.","error":"Error: cannot add job, current queue is finished"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/delvedor/workq#readme","github":"https://github.com/delvedor/workq","docs":null,"changelog":null,"pypi":null,"npm":"workq","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}