summaryrefslogtreecommitdiffstats
path: root/node_modules/run-queue
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/run-queue')
-rw-r--r--node_modules/run-queue/README.md86
-rw-r--r--node_modules/run-queue/package.json63
-rw-r--r--node_modules/run-queue/queue.js95
3 files changed, 0 insertions, 244 deletions
diff --git a/node_modules/run-queue/README.md b/node_modules/run-queue/README.md
deleted file mode 100644
index e84214d..0000000
--- a/node_modules/run-queue/README.md
+++ /dev/null
@@ -1,86 +0,0 @@
-# run-queue
-
-A promise based, dynamic priority queue runner, with concurrency limiting.
-
-```js
-const RunQueue = require('run-queue')
-
-const queue = new RunQueue({
- maxConcurrency: 1
-})
-
-queue.add(1, example, [-1])
-for (let ii = 0; ii < 5; ++ii) {
- queue.add(0, example, [ii])
-}
-const finished = []
-queue.run().then(
- console.log(finished)
-})
-
-function example (num, next) {
- setTimeout(() => {
- finished.push(num)
- next()
- }, 5 - Math.abs(num))
-}
-```
-
-would output
-
-```
-[ 0, 1, 2, 3, 4, -1 ]
-```
-
-If you bump concurrency to `2`, then you get:
-
-```
-[ 1, 0, 3, 2, 4, -1 ]
-```
-
-The concurrency means that they don't finish in order, because some take
-longer than others. Each priority level must finish entirely before the
-next priority level is run. See
-[PRIORITIES](https://github.com/iarna/run-queue#priorities) below. This is
-even true if concurrency is set high enough that all of the regular queue
-can execute at once, for instance, with `maxConcurrency: 10`:
-
-```
-[ 4, 3, 2, 1, 0, -1 ]
-```
-
-## API
-
-### const queue = new RunQueue(options)
-
-Create a new queue. Options may contain:
-
-* maxConcurrency - (Default: `1`) The maximum number of jobs to execute at once.
-* Promise - (Default: global.Promise) The promise implementation to use.
-
-### queue.add (prio, fn, args)
-
-Add a new job to the end of the queue at priority `prio` that will run `fn`
-with `args`. If `fn` is async then it should return a Promise.
-
-### queue.run ()
-
-Start running the job queue. Returns a Promise that resolves when either
-all the jobs are complete or a job ends in error (throws or returns a
-rejected promise). If a job ended in error then this Promise will be rejected
-with that error and no further queue running will be done.
-
-## PRIORITIES
-
-Priorities are any integer value >= 0.
-
-Lowest is executed first.
-
-Priorities essentially represent distinct job queues. All jobs in a queue
-must complete before the next highest priority job queue is executed.
-
-This means that if you have two queues, `0` and `1` then ALL jobs in `0`
-must complete before ANY execute in `1`. If you add new `0` level jobs
-while `1` level jobs are running then it will switch back processing the `0`
-queue and won't execute any more `1` jobs till all of the new `0` jobs
-complete.
diff --git a/node_modules/run-queue/package.json b/node_modules/run-queue/package.json
deleted file mode 100644
index 5cfcb5a..0000000
--- a/node_modules/run-queue/package.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "_from": "run-queue@^1.0.3",
- "_id": "run-queue@1.0.3",
- "_inBundle": false,
- "_integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=",
- "_location": "/run-queue",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "run-queue@^1.0.3",
- "name": "run-queue",
- "escapedName": "run-queue",
- "rawSpec": "^1.0.3",
- "saveSpec": null,
- "fetchSpec": "^1.0.3"
- },
- "_requiredBy": [
- "/copy-concurrently",
- "/move-concurrently"
- ],
- "_resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
- "_shasum": "e848396f057d223f24386924618e25694161ec47",
- "_spec": "run-queue@^1.0.3",
- "_where": "/home/pruss/Dev/3-minute-website/node_modules/move-concurrently",
- "author": {
- "name": "Rebecca Turner",
- "email": "me@re-becca.org",
- "url": "http://re-becca.org/"
- },
- "bugs": {
- "url": "https://github.com/iarna/run-queue/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "aproba": "^1.1.1"
- },
- "deprecated": false,
- "description": "A promise based, dynamic priority queue runner, with concurrency limiting.",
- "devDependencies": {
- "standard": "^8.6.0",
- "tap": "^10.2.0"
- },
- "directories": {
- "test": "test"
- },
- "files": [
- "queue.js"
- ],
- "homepage": "https://npmjs.com/package/run-queue",
- "keywords": [],
- "license": "ISC",
- "main": "queue.js",
- "name": "run-queue",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/iarna/run-queue.git"
- },
- "scripts": {
- "test": "standard && tap -J test"
- },
- "version": "1.0.3"
-}
diff --git a/node_modules/run-queue/queue.js b/node_modules/run-queue/queue.js
deleted file mode 100644
index 500bf29..0000000
--- a/node_modules/run-queue/queue.js
+++ /dev/null
@@ -1,95 +0,0 @@
-'use strict'
-module.exports = RunQueue
-
-var validate = require('aproba')
-
-function RunQueue (opts) {
- validate('Z|O', [opts])
- if (!opts) opts = {}
- this.finished = false
- this.inflight = 0
- this.maxConcurrency = opts.maxConcurrency || 1
- this.queued = 0
- this.queue = []
- this.currentPrio = null
- this.currentQueue = null
- this.Promise = opts.Promise || global.Promise
- this.deferred = {}
-}
-
-RunQueue.prototype = {}
-
-RunQueue.prototype.run = function () {
- if (arguments.length !== 0) throw new Error('RunQueue.run takes no arguments')
- var self = this
- var deferred = this.deferred
- if (!deferred.promise) {
- deferred.promise = new this.Promise(function (resolve, reject) {
- deferred.resolve = resolve
- deferred.reject = reject
- self._runQueue()
- })
- }
- return deferred.promise
-}
-
-RunQueue.prototype._runQueue = function () {
- var self = this
-
- while ((this.inflight < this.maxConcurrency) && this.queued) {
- if (!this.currentQueue || this.currentQueue.length === 0) {
- // wait till the current priority is entirely processed before
- // starting a new one
- if (this.inflight) return
- var prios = Object.keys(this.queue)
- for (var ii = 0; ii < prios.length; ++ii) {
- var prioQueue = this.queue[prios[ii]]
- if (prioQueue.length) {
- this.currentQueue = prioQueue
- this.currentPrio = prios[ii]
- break
- }
- }
- }
-
- --this.queued
- ++this.inflight
- var next = this.currentQueue.shift()
- var args = next.args || []
-
- // we explicitly construct a promise here so that queue items can throw
- // or immediately return to resolve
- var queueEntry = new this.Promise(function (resolve) {
- resolve(next.cmd.apply(null, args))
- })
-
- queueEntry.then(function () {
- --self.inflight
- if (self.finished) return
- if (self.queued <= 0 && self.inflight <= 0) {
- self.finished = true
- self.deferred.resolve()
- }
- self._runQueue()
- }, function (err) {
- self.finished = true
- self.deferred.reject(err)
- })
- }
-}
-
-RunQueue.prototype.add = function (prio, cmd, args) {
- if (this.finished) throw new Error("Can't add to a finished queue. Create a new queue.")
- if (Math.abs(Math.floor(prio)) !== prio) throw new Error('Priorities must be a positive integer value.')
- validate('NFA|NFZ', [prio, cmd, args])
- prio = Number(prio)
- if (!this.queue[prio]) this.queue[prio] = []
- ++this.queued
- this.queue[prio].push({cmd: cmd, args: args})
- // if this priority is higher than the one we're currently processing,
- // switch back to processing its queue.
- if (this.currentPrio > prio) {
- this.currentQueue = this.queue[prio]
- this.currentPrio = prio
- }
-}