Skip to content

Commit

Permalink
Added ability to start a job immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
bugs181 committed May 31, 2020
1 parent 9ca37f0 commit dfdd6b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Queue.prototype.reverse = function () {
return this
}

Queue.prototype.pushImmediate = function () {
Array.prototype.unshift.apply(this.jobs, arguments)
this.start(null, true)
return this
}

var arrayAddMethods = [
'push',
'unshift',
Expand Down Expand Up @@ -75,8 +81,10 @@ Queue.prototype.start = function (cb) {

this.running = true

if (this.pending >= this.concurrency) {
return
if (!startImmediate) {
if (this.pending >= this.concurrency) {
return
}
}

if (this.jobs.length === 0) {
Expand Down

0 comments on commit dfdd6b0

Please sign in to comment.