Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added some more background to the comparison section

  • Loading branch information...
commit 4548abadd5036b4ca308c8295d7ef69999ef8c5b 1 parent dab4120
@balupton balupton authored
Showing with 24 additions and 20 deletions.
  1. +24 −20 README.md
View
44 README.md
@@ -148,25 +148,25 @@ new (require('taskgroup')).Task()
## Comparison with [Async.js](https://github.com/caolan/async)
-The advantage of TaskGroup over async.js is that TaskGroup has one uniform API to rule them all, whereas with async.js I found that I was always having to keep referring to the async manual to try and figure out which is the right call for my use case then somehow wrap my head around the async.js way of doing things (which more often than not I couldn't), whereas with TaskGroup I never have that problem as it is one consistent API for all the different use cases.
+The biggest advantage and difference of TaskGroup over async.js is that TaskGroup has one uniform API to rule them all, whereas with async.js I found that I was always having to keep referring to the async manual to try and figure out which is the right call for my use case then somehow wrap my head around the async.js way of doing things (which more often than not I couldn't), whereas with TaskGroup I never have that problem as it is one consistent API for all the different use cases.
Let's take a look at what the most common async.js methods would look like in TaskGroup:
``` javascript
// ====================================
-// Map
+// Series
// Async
-async.map(['file1','file2','file3'], fs.stat, next);
+async.series([
+ function(){},
+ function(callback){callback();}
+], next);
// TaskGroup
-var tasks = new TaskGroup().setConfig({concurrency:0}).once('complete',next);
-['file1','file2','file3'].forEach(function(file){
- tasks.addTask(function(complete){
- fs.stat(file,complete);
- });
-});
-tasks.run();
+new TaskGroup().once('complete', next)
+ .addTask(function(){})
+ .addTask(function(callback){callback();})
+ .run();
// ====================================
@@ -179,28 +179,32 @@ async.parallel([
], next);
// TaskGroup
-new TaskGroup().setConfig({concurrency:0}).once('complete',next)
+new TaskGroup().setConfig({concurrency:0}).once('complete', next)
.addTask(function(){})
.addTask(function(callback){callback();})
.run();
// ====================================
-// Series
+// Map
// Async
-async.series([
- function(){},
- function(callback){callback();}
-], next);
+async.map(['file1','file2','file3'], fs.stat, next);
// TaskGroup
-new TaskGroup().once('complete',next)
- .addTask(function(){})
- .addTask(function(callback){callback();})
- .run();
+var tasks = new TaskGroup().setConfig({concurrency:0}).once('complete', next);
+['file1','file2','file3'].forEach(function(file){
+ tasks.addTask(function(complete){
+ fs.stat(file,complete);
+ });
+});
+tasks.run();
```
+Another big advantage of TaskGroup over async.js is TaskGroup's ability to add tasks to the group once execution has already started - this is a common use case when creating an application that must perform it's actions serially, so using TaskGroup you can create a serial TaskGroup for the application, run it right away, then add the actions to the group as tasks.
+
+A final big advantage of TaskGroup over async.js is TaskGroup's ability to do nested groups, this allowed us to created the [Joe Testing Framework & Runner](https://github.com/bevry/joe) incredibly easily, and because of this functionality Joe will always know which test (task) is associated to which suite (task group), whereas test runners like mocha have to guess (they add the task to the last group, which may not always be the case! especially with dynamically created tests!).
+
## History
Please sign in to comment.
Something went wrong with that request. Please try again.