{ "_id": "run-queue", "_rev": "6-152e9fa845e18d5defdb06fe10849a0b", "name": "run-queue", "description": "A promise based, dynamic priority queue runner, with concurrency limiting.", "dist-tags": { "latest": "2.0.1" }, "versions": { "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", "tarball": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.0.tgz" }, "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/run-queue-1.0.0.tgz_1488149007258_0.8681126337032765" } }, "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", "tarball": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.1.tgz" }, "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/run-queue-1.0.1.tgz_1488154288448_0.6650912221521139" } }, "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", "tarball": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.2.tgz" }, "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/run-queue-1.0.2.tgz_1488154367416_0.6272554455790669" } }, "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", "tarball": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz" }, "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "_npmOperationalInternal": { "host": "packages-18-east.internal.npmjs.com", "tmp": "tmp/run-queue-1.0.3.tgz_1488161288446_0.14580746600404382" } }, "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": { "integrity": "sha512-/9w+VOBVduLMu6x6GBF2C4YgRX3xHGFu/Nyzk61y0mLZb6tAeDP9rZ9hX7r3AbheR2lx2tltqjXaKfuOuul7Ow==", "shasum": "6d6a48c5291fa50b0ccb0b60ae5fdf77c9979643", "tarball": "https://registry.npmjs.org/run-queue/-/run-queue-2.0.0.tgz", "fileCount": 4, "unpackedSize": 6488, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbjvrHCRA9TVsSAnZWagAAI3wP/0tmfFyw6nD2sY3GwBsa\nu3MeZ7kcHdmCvl1IwgfB63Y/B3WOf9aeJQqzwSbxpI6OyfbX9hvqQqM/Jnxn\ninpHV5QEf1j6ud7giucM7uiZaFGQc+A/0Xjok52+TaL9xeZFV4jtIR1MBxEy\nd8EzpaDRd56bHpdRR/gJH7MvFo6adErx0oRQez54HbT5w9CnR2zk31t8eWVD\n+O8RIp9bq0fGU8fg1FhsrJvY8u1i0fHqlrvMQliatPCXlGZAGOrbxtUzNTyV\nXo1/zat150zifAHW7FQxw59G/rWAyPN6q8ULEGR/KGZMUl6SFFJPgMHEvX3n\nvsrGHGM59LQzzwhq+IO/qepES6CVRLJUdQt40LkTxIgUxWo/NzN4oiy2RVnB\nqcy4hZF+oiYlQs3JhdaBazwkNYTuCnJfApkUacp2XFYVznMGpwFpzojYV5go\nAOCXON2JOfRczahUOJ5JyW0uPwXcmNoCEN//hNWQ5D84L0kMt4kh3NeDOIn4\nj6KP64fwELl82lWb5+zIADuNJFq0Msua4Bm7FspmiVa/99VceVvzIRT3j/1M\np4TVGWtqp9tNVD3p0r45Hxjno9vwWGED+dxxm961PwWh64WWd3QmUt3Zjyve\nRmUlFFAKplKGBLsxsICeLTLdZGbzZPQv7Kd4zRxRPSpr+/ZjSiio/3yHo1C6\n55Y2\r\n=xIko\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/run-queue_2.0.0_1536096967105_0.7691035061880602" }, "_hasShrinkwrap": false }, "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": { "integrity": "sha512-dkU5pUwpmeNKdsApBU6eBdUdkoSwx+yRnoi3Ax745evJDNx7NQRsE2o3AsXbye5GqbKqZ9HJFYxZ2laOoNE1Dg==", "shasum": "2fa9302a32897f3d7bd8b2267842272804d7db11", "tarball": "https://registry.npmjs.org/run-queue/-/run-queue-2.0.1.tgz", "fileCount": 4, "unpackedSize": 6535, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcS7IzCRA9TVsSAnZWagAAFKMP/Rn6Mou/8CX1FDzhk5Ph\nxhKUWeu//52pQdrKLuoFEALrZd2TIUGIr2n37GIdw79e4wK9hilj7Z6onSKG\nz65fKtr2rd8S3YxvpATynDj+xc+B8RuWnHi3BJULlThNf3/+/nglBVbbe9qg\nAgssiI343GICCM0eldGa74srZxzE9Ypjk9U/MmuBDFJBvWBsnv6mm5YsHJix\nDcmfkSj9/v/JOldmilFk2E4O8kUC0DMl5z9mjq7RMiHc8iKyUoNDO+snWgHF\nPmcAO/xrZt7wIt4Jfgbi2tIXX85hoemUtVC7TRstnuEJYU+nLrhWmPdfUdC8\nOhdinWT8UcBPX8V3fyEoSrmXaIjeAOyC8vYuFBx+ucIR70hkT8SPqt2odqRw\n3kJIGJ6XyG54ul8QAGrEuVKx6RSMi7nJHOZ4/mtHWoIbMFo27lcLyVIfd2RN\np3cK3YgY7yFkFG0G6/vHZWtL5OxmJE0PMBbaK3d0McUkjw/YPC69+VKAoh9x\nR8rFdWCbVig3WQxzJ98D0QNYlFA3TQ67v4E9u6XN2Epwq3lJrLEVsWrpAm9k\nEdXm8imQs1UlZz3ejjsM/2P8U0uZSp/jb94W+eT3zYg1BR3j3J/eWJiHKKTa\nJeLOFP2xI9pNUEB4l4yHyS2Yw56S4MJ4OUsWwsuMPKwVnJPivp7HJNckxeLM\nP3Ub\r\n=k5D9\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/run-queue_2.0.1_1548464690940_0.443462412986239" }, "_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", "maintainers": [ { "name": "iarna", "email": "me@re-becca.org" } ], "time": { "modified": "2019-01-26T01:04:53.736Z", "created": "2017-02-26T22:43:27.507Z", "1.0.0": "2017-02-26T22:43:27.507Z", "1.0.1": "2017-02-27T00:11:28.664Z", "1.0.2": "2017-02-27T00:12:47.664Z", "1.0.3": "2017-02-27T02:08:10.231Z", "2.0.0": "2018-09-04T21:36:07.290Z", "2.0.1": "2019-01-26T01:04:51.121Z" }, "homepage": "https://npmjs.com/package/run-queue", "keywords": [], "repository": { "type": "git", "url": "git+https://github.com/iarna/run-queue.git" }, "author": { "name": "Rebecca Turner", "email": "me@re-becca.org", "url": "http://re-becca.org/" }, "bugs": { "url": "https://github.com/iarna/run-queue/issues" }, "license": "ISC", "readmeFilename": "README.md", "users": { "iarna": true } }