Comparing version 2.1.2 to 2.2.0
26
index.js
@@ -29,2 +29,3 @@ /** | ||
this.session = 0; | ||
this.running = false; | ||
this.jobs = []; | ||
@@ -49,9 +50,7 @@ } | ||
for (var method in arrayMethods) { | ||
(function(method) { | ||
Queue.prototype[method] = function() { | ||
return Array.prototype[method].apply(this.jobs, arguments); | ||
}; | ||
})(arrayMethods[method]); | ||
} | ||
for (var method in arrayMethods) (function(method) { | ||
Queue.prototype[method] = function() { | ||
return Array.prototype[method].apply(this.jobs, arguments); | ||
}; | ||
})(arrayMethods[method]); | ||
@@ -104,3 +103,3 @@ /** | ||
done.call(self); | ||
} else { | ||
} else if (self.running) { | ||
self.start(); | ||
@@ -124,2 +123,3 @@ } | ||
this.pending++; | ||
this.running = true; | ||
job(next); | ||
@@ -133,2 +133,9 @@ | ||
/** | ||
* stop / pause | ||
*/ | ||
Queue.prototype.stop = function() { | ||
this.running = false; | ||
}; | ||
/** | ||
* clear the queue including any running jobs | ||
@@ -149,4 +156,5 @@ */ | ||
function done(err) { | ||
this.session++; | ||
this.running = false; | ||
this.emit('end', err); | ||
this.session++; | ||
}; |
{ | ||
"name": "queue", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "async job queue with adjustable concurrency", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -20,3 +20,4 @@ ``` | ||
* `start()` | ||
* `end([err])` if you pass a `err` it will be available to 'end' event handlers when triggered | ||
* `stop()` | ||
* `end([err])` stop and empty the queue immediately | ||
@@ -23,0 +24,0 @@ inherited from `Array`: |
@@ -6,2 +6,3 @@ require('./synchronous'); | ||
require('./error'); | ||
require('./stop'); | ||
require('./end'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12271
13
403
131