taskgroup
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -17,4 +17,6 @@ // Generated by CoffeeScript 1.6.2 | ||
Task.prototype.completed = false; | ||
Task.prototype.result = null; | ||
Task.prototype.running = false; | ||
Task.prototype.parent = null; | ||
@@ -71,5 +73,7 @@ | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
_this.completed = true; | ||
return _this.emit.apply(_this, ['complete'].concat(__slice.call(args))); | ||
_this.running = false; | ||
_this.result = args; | ||
return _this.complete(); | ||
}; | ||
this.running = true; | ||
this.emit('run'); | ||
@@ -85,2 +89,12 @@ process.nextTick(function() { | ||
Task.prototype.complete = function() { | ||
var completed; | ||
completed = (this.result != null) && this.running === false; | ||
if (completed) { | ||
this.emit.apply(this, ['complete'].concat(__slice.call(this.result))); | ||
} | ||
return completed; | ||
}; | ||
return Task; | ||
@@ -201,2 +215,17 @@ | ||
TaskGroup.prototype.getTotals = function() { | ||
var completed, remaining, running, total; | ||
running = this.running; | ||
remaining = this.remaining.length; | ||
completed = this.results.length; | ||
total = running + remaining + completed; | ||
return { | ||
running: running, | ||
remaining: remaining, | ||
completed: completed, | ||
total: total | ||
}; | ||
}; | ||
TaskGroup.prototype.addItem = function(item) { | ||
@@ -203,0 +232,0 @@ var me; |
{ | ||
"name": "taskgroup", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "Group together synchronous and asynchronous tasks and execute them with support for concurrency, naming, and nesting.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/bevry/taskgroup", |
@@ -102,2 +102,3 @@ # Task Group | ||
- `addGroup(args...)` - create a new group item with the arguments and adds it to the group, returns the new group item | ||
- `getTotals()` - returns counts for the following `{running,remaining,completed,total}` | ||
- `clear()` - remove the remaining items to be executed | ||
@@ -107,2 +108,3 @@ - `pause()` - pause the execution of the items | ||
- `exit(err)` - stop and complete, `err` if specified is sent to the completion event when fired | ||
- `complete()` - will fire the completion event if we are already complete, useful if you're binding your listeners after run | ||
- `run()` - start/resume executing the items, returns chain | ||
@@ -136,2 +138,3 @@ - All those of [EventEmitter2](https://github.com/hij1nx/EventEmitter2) | ||
- `setConfig(config)` - set the configuration for the group, returns chain | ||
- `complete()` - will fire the completion event if we are already complete, useful if you're binding your listeners after run | ||
- `run()` - execute the task | ||
@@ -138,0 +141,0 @@ - Available configuration: |
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
20030
390
157