{"id":26058916,"url":"https://github.com/zackiles/bluebird-queue","last_synced_at":"2025-04-11T05:51:54.383Z","repository":{"id":30526143,"uuid":"34080685","full_name":"zackiles/bluebird-queue","owner":"zackiles","description":"Create promise queues with Bluebird promises. Add concurrency and delays.","archived":false,"fork":false,"pushed_at":"2016-09-28T18:26:54.000Z","size":14,"stargazers_count":14,"open_issues_count":7,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T11:53:57.614Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zackiles.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-16T21:08:14.000Z","updated_at":"2021-12-17T08:05:56.000Z","dependencies_parsed_at":"2022-09-22T12:52:12.847Z","dependency_job_id":null,"html_url":"https://github.com/zackiles/bluebird-queue","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fbluebird-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fbluebird-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fbluebird-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fbluebird-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackiles","download_url":"https://codeload.github.com/zackiles/bluebird-queue/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351410,"owners_count":21089271,"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":[],"created_at":"2025-03-08T12:40:57.872Z","updated_at":"2025-04-11T05:51:54.344Z","avatar_url":"https://github.com/zackiles.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bluebird Queue\n[![npm version](https://badge.fury.io/js/bluebird-queue.svg)](http://badge.fury.io/js/bluebird-queue)\n\nCreate promise queues with Bluebird promises. Add concurrency and delays.\n\n## Installation\n\nYou know the drill.\n\n```sh\n$ npm install bluebird-queue\n```\n\n### Constructor Options\n\n#### concurrency\nType: `Integer`\nDefault 4\n\nThe amount of promises that will be simultaneously resolved in order.\n\n#### delay\nType: `Integer`\nIn milliseconds. Default 0\n\nAn optional delay to add to each promise.\n\n#### interval\nType: `Integer`\nIn milliseconds. Default 0\n\nAn optional interval that queued promises will recheck the queue when it is full. The more promises you attempt to queue past concurrency, the more the interval will effect performance.\n\n#### onComplete\nType: `Callback`\nOptional.\n\nIs called everytime all items in the queue are processed. The start() method also returns a promise that is resolved on completion.\n\n#### onError\nType: `Callback`\nOptional.\n\nIs called everytime there is an error. The start() method also returns a promise that is rejected on error.\n\n### Overview\n\nYou can use the queue in two ways:\n\n- Manually adding items with the add() method then calling start() which returns a promise that resolves an array of the resolved queued promises. The add() method will not start resolving queued promises until start() is called.\n- Attaching a callback to onComplete and using the addNow() method which will start processing the queue right away.\n\nStarting and using queue is simple. You can add any of the options listed above to the new BlueBirdQueue constructor \nwhich takes an object.\n\n``` js\nvar BlueBirdQueue = require('bluebird-queue'),\n    Promise = require('bluebird'),\n    fs = Promise.promisifyAll(require('fs')),\n    queue = new BlueBirdQueue({\n      concurrency: 5 // optional, how many items to process at a time\n    });\n\nvar bookPromise = function(name){\n  return getBookByNamePromise(name);\n};\n\n// only create a reference to the function, don't actually call it.\nvar bookPromise1 = bookPromise.bind(null, 'some book');\nvar bookPromise2 = bookPromise.bind(null, 'another book');\n\n// add multiple promises or promises-making functions to the queue in one call\nqueue.add([bookPromise1, bookPromise2]);\n// can also be called with a single function and no array\nqueue.add(fs.readFileAsync('package.json'));\nqueue.start().then(function(results){\n  console.log(results);\n});\n\n```\n\n### Methods\n\n#### add()\nParameters: `function, promise or array of function or promise references`\nReturns: `nothing`\n\nAdds a promise reference to the queue. Does not resolve the promise until start() is called. Can be passed a single \npromise returning function, a promise, or an array of promises or promise returning functions.\n\n#### addNow()\nParameters: `function, array of arguments`\nReturns: `nothing`\n\nUtility method. Same as the add() method, but adds the item and starts processing without the need to call start.\n\n#### start()\nParameters: `none`\nReturns: `promise`\n\nStarts processing the queued items and returns a promise that that resolves the results from all their resolved values.\n\n#### drain()\nParameters: `none`\nReturns: `nothing`\n\nImmediately resolves all queued promises at once, ignoring concurrency, and frees any resources that were used. Will call the onComplete callback when it's finished.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackiles%2Fbluebird-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackiles%2Fbluebird-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackiles%2Fbluebird-queue/lists"}