Skip to content

Commit

Permalink
guard
Browse files Browse the repository at this point in the history
  • Loading branch information
mstdokumaci committed Oct 26, 2016
1 parent 5d87079 commit ba01bf8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ module.exports = (limit) => {
const step = this.steps[this.steps.keys()[task.step]]

task.state = 'running'
const thisStep = task.step

task.timeout = setTimeout(() => {
if (task.step !== thisStep) {
return
}
if (task.abort && task.abort.constructor === Function) {
task.abort()
}
Expand All @@ -123,10 +127,16 @@ module.exports = (limit) => {
task.abort = step.run(
task,
data => {
if (task.step !== thisStep) {
return
}
task.completeStep(data)
this.debounceRun()
},
error => {
if (task.step !== thisStep) {
return
}
task.error(error)
this.debounceRun()
}
Expand Down

0 comments on commit ba01bf8

Please sign in to comment.