{"id":46353,"library":"sg-queue","title":"sg-queue","description":"A minimal Node.js task queue for executing asynchronous functions sequentially. Version 1.1.4. It ensures that tasks are processed one after another in order, returning a promise that resolves when all tasks complete. Suitable for use with generators and promises. No external dependencies. Supports Node.js >=6.","status":"active","version":"1.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/realglobe-inc/sg-queue","tags":["javascript","SUGOS"],"install":[{"cmd":"npm install sg-queue","lang":"bash","label":"npm"},{"cmd":"yarn add sg-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add sg-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package uses CommonJS and exports a function directly.","wrong":"const sgQueue = require('sg-queue').default","symbol":"sgQueue","correct":"const sgQueue = require('sg-queue')"},{"note":"For ES modules, default import works with Node.js >=12 if using --experimental-modules or esm package.","wrong":"import { sgQueue } from 'sg-queue'","symbol":"sgQueue","correct":"import sgQueue from 'sg-queue'"},{"note":"sg-queue is a function, not a constructor. Call it directly without 'new'.","wrong":"let queue = new sgQueue()","symbol":"sgQueue","correct":"let queue = sgQueue()"}],"quickstart":{"code":"const sgQueue = require('sg-queue');\n\n// Create a sequential queue\nconst queue = sgQueue();\n\n// Add tasks\nqueue.push(() => new Promise(resolve => {\n  setTimeout(() => resolve('Task 1 done'), 100);\n}));\nqueue.push(() => new Promise(resolve => {\n  setTimeout(() => resolve('Task 2 done'), 50);\n}));\n\n// Wait for all tasks to complete\nqueue.then(() => {\n  console.log('All tasks finished');\n}).catch(err => console.error(err));","lang":"javascript","description":"This shows how to create a queue, push tasks, and wait for completion."},"warnings":[{"fix":"Design your application to handle queued tasks as fire-and-forget or use a library that supports cancellation.","message":"sg-queue does not expose a way to cancel or clear tasks once pushed. Pushed tasks will execute even if the queue promise is ignored.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Capture results by appending .then() to the return of queue.push(), as shown in the usage example.","message":"The queue does not return results per task; you must chain .then() on each push to collect individual results.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"For modern Node.js (>=14), consider using a more actively maintained queue library like 'p-queue' or 'async.queue'.","message":"The package uses 'require('sg-queue')' with callback-based Node.js patterns and does not support ES modules natively (no 'exports' field in package.json).","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"If you need concurrency, choose a dedicated async task queue like 'p-queue' (supports concurrency limit).","message":"The queue does not provide concurrency control; all tasks run one at a time sequentially, which may be a bottleneck for I/O-heavy workloads.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.1.4':15 '6':48 'anoth':24 'asynchron':11 'complet':35 'depend':45 'ensur':17 'execut':10 'extern':44 'function':12 'generat':40 'javascript':49 'minim':5 'node.js':6,47 'one':22 'order':26 'process':21 'promis':29,42 'queue':3,8 'resolv':31 'return':27 'sequenti':13 'sg':2 'sg-queue':1 'sugo':50 'suitabl':36 'support':46 'task':7,19,34 'use':38 'version':14","created_at":"2026-06-07T12:59:30.708050+00:00","updated_at":"2026-06-07T12:59:30.708050+00:00","problems":[{"fix":"Remove 'new'; just call sgQueue() as a normal function.","cause":"Calling 'new sgQueue()' instead of 'sgQueue()'.","error":"TypeError: sgQueue is not a constructor"},{"fix":"Run 'npm install sg-queue --save' in your project root.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'sg-queue'"},{"fix":"Ensure you require the function and call it to create a queue object. queue.push is available before queue.then() resolves.","cause":"Requiring the module incorrectly or using it after the queue's promise resolves.","error":"TypeError: queue.push is not a function"}],"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/realglobe-Inc/sg-queue#readme","github":"https://github.com/realglobe-inc/sg-queue","docs":null,"changelog":null,"pypi":null,"npm":"sg-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"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}}