{"_id":"run-queue","_rev":"97070","name":"run-queue","description":"A promise based, dynamic priority queue runner, with concurrency limiting.","dist-tags":{"latest":"2.0.1"},"maintainers":[{"name":"iarna","email":""}],"time":{"modified":"2021-06-03T10:32:34.000Z","created":"2017-02-26T22:43:27.507Z","2.0.1":"2019-01-26T01:04:51.121Z","2.0.0":"2018-09-04T21:36:07.290Z","1.0.3":"2017-02-27T02:08:10.231Z","1.0.2":"2017-02-27T00:12:47.664Z","1.0.1":"2017-02-27T00:11:28.664Z","1.0.0":"2017-02-26T22:43:27.507Z"},"users":{"iarna":true},"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"versions":{"2.0.1":{"name":"run-queue","version":"2.0.1","description":"A promise based, dynamic priority queue runner, with concurrency limiting.","main":"queue.js","scripts":{"test":"iarna-standard && tap --100 test","test-v4":"tap --100 test"},"keywords":[],"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"license":"ISC","devDependencies":{"@iarna/standard":"^2.0.0","tap":"^12.4.0"},"directories":{"test":"test"},"dependencies":{"aproba":"^2.0.0"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"bugs":{"url":"https://github.com/iarna/run-queue/issues"},"homepage":"https://npmjs.com/package/run-queue","gitHead":"cbbe521279426e1786fc494ee1b9b695e1b9bd9e","_id":"run-queue@2.0.1","_nodeVersion":"10.11.0","_npmVersion":"6.6.0","_npmUser":{"name":"iarna","email":"me@re-becca.org"},"dist":{"shasum":"2fa9302a32897f3d7bd8b2267842272804d7db11","size":2956,"noattachment":false,"key":"/run-queue/-/run-queue-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/run-queue/download/run-queue-2.0.1.tgz"},"maintainers":[{"name":"iarna","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/run-queue_2.0.1_1548464690940_0.443462412986239"},"_hasShrinkwrap":false,"publish_time":1548464691121,"_cnpm_publish_time":1548464691121},"2.0.0":{"name":"run-queue","version":"2.0.0","description":"A promise based, dynamic priority queue runner, with concurrency limiting.","main":"queue.js","scripts":{"test":"standard && tap -J --100 test"},"keywords":[],"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"license":"ISC","devDependencies":{"standard":"^8.6.0","tap":"^10.2.0"},"directories":{"test":"test"},"dependencies":{"aproba":"^1.1.1"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"bugs":{"url":"https://github.com/iarna/run-queue/issues"},"homepage":"https://npmjs.com/package/run-queue","gitHead":"a302a574191ae2c7a184d1479216f47725efbd0e","_id":"run-queue@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.6.0","_npmUser":{"name":"iarna","email":"me@re-becca.org"},"dist":{"shasum":"6d6a48c5291fa50b0ccb0b60ae5fdf77c9979643","size":2945,"noattachment":false,"key":"/run-queue/-/run-queue-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/run-queue/download/run-queue-2.0.0.tgz"},"maintainers":[{"name":"iarna","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/run-queue_2.0.0_1536096967105_0.7691035061880602"},"_hasShrinkwrap":false,"publish_time":1536096967290,"_cnpm_publish_time":1536096967290},"1.0.3":{"name":"run-queue","version":"1.0.3","description":"A promise based, dynamic priority queue runner, with concurrency limiting.","main":"queue.js","scripts":{"test":"standard && tap -J test"},"keywords":[],"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"license":"ISC","devDependencies":{"standard":"^8.6.0","tap":"^10.2.0"},"files":["queue.js"],"directories":{"test":"test"},"dependencies":{"aproba":"^1.1.1"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"bugs":{"url":"https://github.com/iarna/run-queue/issues"},"homepage":"https://npmjs.com/package/run-queue","gitHead":"3c315b738d0578c2c54be2beb0469d00ccf1dc25","_id":"run-queue@1.0.3","_shasum":"e848396f057d223f24386924618e25694161ec47","_from":".","_npmVersion":"2.15.0","_nodeVersion":"0.12.13","_npmUser":{"name":"iarna","email":"me@re-becca.org"},"dist":{"shasum":"e848396f057d223f24386924618e25694161ec47","size":2458,"noattachment":false,"key":"/run-queue/-/run-queue-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/run-queue/download/run-queue-1.0.3.tgz"},"maintainers":[{"name":"iarna","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/run-queue-1.0.3.tgz_1488161288446_0.14580746600404382"},"publish_time":1488161290231,"_cnpm_publish_time":1488161290231,"_hasShrinkwrap":false},"1.0.2":{"name":"run-queue","version":"1.0.2","description":"A promise based, dynamic priority queue runner, with concurrency limiting.","main":"queue.js","scripts":{"test":"standard && tap -J test"},"keywords":[],"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"license":"ISC","devDependencies":{"standard":"^8.6.0","tap":"^10.2.0"},"files":["queue.js"],"directories":{"test":"test"},"dependencies":{"standard":"^8.6.0"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"bugs":{"url":"https://github.com/iarna/run-queue/issues"},"homepage":"https://npmjs.com/package/run-queue","gitHead":"1fb0c4025eb91fb65b0492d626f9f876432b4a50","_id":"run-queue@1.0.2","_shasum":"a9396e5962a5b0b022a81c125017e95302a6f76a","_from":".","_npmVersion":"4.4.0","_nodeVersion":"4.6.1","_npmUser":{"name":"iarna","email":"me@re-becca.org"},"dist":{"shasum":"a9396e5962a5b0b022a81c125017e95302a6f76a","size":2379,"noattachment":false,"key":"/run-queue/-/run-queue-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/run-queue/download/run-queue-1.0.2.tgz"},"maintainers":[{"name":"iarna","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/run-queue-1.0.2.tgz_1488154367416_0.6272554455790669"},"publish_time":1488154367664,"_cnpm_publish_time":1488154367664,"_hasShrinkwrap":false},"1.0.1":{"name":"run-queue","version":"1.0.1","description":"Process a dynamic queue of data, possibly concurrently","main":"queue.js","scripts":{"test":"standard && tap -J test"},"keywords":[],"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"license":"ISC","devDependencies":{"standard":"^8.6.0","tap":"^10.2.0"},"files":["queue.js"],"directories":{"test":"test"},"dependencies":{"standard":"^8.6.0"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"bugs":{"url":"https://github.com/iarna/run-queue/issues"},"homepage":"https://npmjs.com/package/run-queue","gitHead":"2fc7ffce3f7ed31ecd17ae16a792beab43b948ad","_id":"run-queue@1.0.1","_shasum":"f4b0ab80b75f416aea140b13f059af1224844710","_from":".","_npmVersion":"4.4.0","_nodeVersion":"4.6.1","_npmUser":{"name":"iarna","email":"me@re-becca.org"},"dist":{"shasum":"f4b0ab80b75f416aea140b13f059af1224844710","size":2475,"noattachment":false,"key":"/run-queue/-/run-queue-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/run-queue/download/run-queue-1.0.1.tgz"},"maintainers":[{"name":"iarna","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/run-queue-1.0.1.tgz_1488154288448_0.6650912221521139"},"publish_time":1488154288664,"_cnpm_publish_time":1488154288664,"_hasShrinkwrap":false},"1.0.0":{"name":"run-queue","version":"1.0.0","description":"Process a dynamic queue of data, possibly concurrently","main":"queue.js","scripts":{"test":"standard && tap -J test"},"keywords":[],"author":{"name":"Rebecca Turner","email":"me@re-becca.org","url":"http://re-becca.org/"},"license":"ISC","devDependencies":{"standard":"^8.6.0","tap":"^10.2.0"},"files":["queue.js"],"directories":{"test":"test"},"dependencies":{"standard":"^8.6.0"},"repository":{"type":"git","url":"git+https://github.com/iarna/run-queue.git"},"bugs":{"url":"https://github.com/iarna/run-queue/issues"},"homepage":"https://npmjs.com/package/run-queue","gitHead":"f0e7a12f9720352ee386e2c2ce5be9c0bd4c3b7f","_id":"run-queue@1.0.0","_shasum":"5d4da75ba1589e9aec294d3fce987dd60f1def3d","_from":".","_npmVersion":"4.4.0","_nodeVersion":"4.6.1","_npmUser":{"name":"iarna","email":"me@re-becca.org"},"dist":{"shasum":"5d4da75ba1589e9aec294d3fce987dd60f1def3d","size":2490,"noattachment":false,"key":"/run-queue/-/run-queue-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/run-queue/download/run-queue-1.0.0.tgz"},"maintainers":[{"name":"iarna","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/run-queue-1.0.0.tgz_1488149007258_0.8681126337032765"},"publish_time":1488149007507,"_cnpm_publish_time":1488149007507,"_hasShrinkwrap":false}},"readme":"# run-queue\n\nA promise based, dynamic priority queue runner, with concurrency limiting.\n\n```js\nconst RunQueue = require('run-queue')\n\nconst queue = new RunQueue({\n  maxConcurrency: 1\n})\n\nqueue.add(1, example, [-1])\nfor (let ii = 0; ii < 5; ++ii) {\n  queue.add(0, example, [ii])\n}\nconst finished = []\nqueue.run().then(\n  console.log(finished)\n})\n\nfunction example (num, next) {\n  setTimeout(() => {\n    finished.push(num)\n    next()\n  }, 5 - Math.abs(num))\n}\n```\n\nwould output\n\n```\n[ 0, 1, 2, 3, 4, -1 ]\n```\n\nIf you bump concurrency to `2`, then you get:\n\n```\n[ 1, 0, 3, 2, 4, -1 ]\n```\n\nThe concurrency means that they don't finish in order, because some take\nlonger than others.  Each priority level must finish entirely before the\nnext priority level is run.  See\n[PRIORITIES](https://github.com/iarna/run-queue#priorities) below.  This is\neven true if concurrency is set high enough that all of the regular queue\ncan execute at once, for instance, with `maxConcurrency: 10`:\n\n```\n[ 4, 3, 2, 1, 0, -1 ]\n```\n\n## API\n\n### const queue = new RunQueue(options)\n\nCreate a new queue. Options may contain:\n\n* maxConcurrency - (Default: `1`) The maximum number of jobs to execute at once.\n* Promise - (Default: global.Promise) The promise implementation to use.\n\n### queue.add (prio, fn, args)\n\nAdd a new job to the end of the queue at priority `prio` that will run `fn`\nwith `args`. If `fn` is async then it should return a Promise.\n\n### queue.run ()\n\nStart running the job queue.  Returns a Promise that resolves when either\nall the jobs are complete or a job ends in error (throws or returns a\nrejected promise). If a job ended in error then this Promise will be rejected\nwith that error and no further queue running will be done.\n\n## PRIORITIES\n\nPriorities are any integer value >= 0.\n\nLowest is executed first.\n\nPriorities essentially represent distinct job queues.  All jobs in a queue\nmust complete before the next highest priority job queue is executed.\n\nThis means that if you have two queues, `0` and `1` then ALL jobs in `0`\nmust complete before ANY execute in `1`.  If you add new `0` level jobs\nwhile `1` level jobs are running then it will switch back processing the `0`\nqueue and won't execute any more `1` jobs till all of the new `0` jobs\ncomplete.\n","_attachments":{},"homepage":"https://npmjs.com/package/run-queue","bugs":{"url":"https://github.com/iarna/run-queue/issues"},"license":"ISC"}