{"id":46062,"library":"ready-queue","title":"ready-queue","description":"A lightweight Node.js library (v1.0.0) that ensures an initialization function runs only once for a given set of arguments, while queuing and resolving multiple listeners that register before the function completes. Provides built-in retry support on failure. Ideal for deduplicating async operations like data fetching or resource initialization.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/kaelzhang/node-ready-queue","tags":["javascript","ready-queue","queue","ready","retry","promise"],"install":[{"cmd":"npm install ready-queue","lang":"bash","label":"npm"},{"cmd":"yarn add ready-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add ready-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS only. Using ES import may fail in default Node.js environments.","wrong":"import queue from 'ready-queue'","symbol":"queue","correct":"const queue = require('ready-queue')"},{"note":"No named exports exist. The package exports a single function.","wrong":"import { ReadyQueue } from 'ready-queue'","symbol":"ReadyQueue","correct":"const queue = require('ready-queue')"},{"note":"CommonJS require returns the function directly, not as a default property.","wrong":"const { default: queue } = require('ready-queue')","symbol":"default export","correct":"const queue = require('ready-queue')"}],"quickstart":{"code":"const queue = require('ready-queue');\n\nconst q = queue({\n  load: (userId) => {\n    // Simulate async fetch (returns promise)\n    return Promise.resolve({ id: userId, name: 'User' + userId });\n  },\n  retry: 1\n});\n\nq.add(123).then(user => {\n  console.log(user); // First call triggers load(123)\n});\n\nq.add(123).then(user => {\n  // Same arguments, load is not called again\n});\n\nq.add(456).then(user => {\n  // Different arguments triggers new load(456)\n});","lang":"javascript","description":"Creates a queue that deduplicates calls to load with the same arguments and queues listeners until the promise resolves."},"warnings":[{"fix":"Ensure load returns a promise if async, or a truthy value if sync.","message":"The load function must return a Promise or a synchronous value. If it returns undefined, the queue will resolve immediately with undefined.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Implement your own timeout wrapper around the queue if needed.","message":"The .add() method returns a Promise that resolves with the result of load. It does not support cancellation or timeout.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Create a .d.ts file: declare module 'ready-queue';","message":"This package has no TypeScript type definitions. Using it in TypeScript may require custom type declarations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Implement your own retry logic with backoff if needed.","message":"The 'retry' option integer specifies number of retries on failure, but does not implement exponential backoff.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'argument':22 'async':46 'built':37 'built-in':36 'complet':34 'data':49 'dedupl':45 'ensur':10 'failur':42 'fetch':50 'function':13,33 'given':19 'ideal':43 'initi':12,53 'javascript':54 'librari':7 'lightweight':5 'like':48 'listen':28 'multipl':27 'node.js':6 'oper':47 'promis':61 'provid':35 'queu':24 'queue':3,57,58 'readi':2,56,59 'ready-queu':1,55 'regist':30 'resolv':26 'resourc':52 'retri':39,60 'run':14 'set':20 'support':40 'v1.0.0':8","created_at":"2026-06-07T12:58:06.537508+00:00","updated_at":"2026-06-07T12:58:06.537508+00:00","problems":[{"fix":"Use require('ready-queue') instead of import.","cause":"Using ES import (import queue from 'ready-queue') on this CommonJS-only package may result in undefined.","error":"TypeError: queue 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/kaelzhang/node-ready-queue#readme","github":"git://github.com/kaelzhang/node-ready-queue","docs":null,"changelog":null,"pypi":null,"npm":"ready-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","database"],"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}}