Skip to content
Browse files

Added async.js comparison to the readme

  • Loading branch information...
1 parent 475fda2 commit 8b6f3015b7730f8bf6c2d636f003c7facea84fca @balupton balupton committed Apr 29, 2013
Showing with 56 additions and 0 deletions.
  1. +56 −0 README.md
View
56 README.md
@@ -145,6 +145,62 @@ new (require('taskgroup')).Task()
- `complete(err, args...)` - fired when the task has completed
+### [Async.js](https://github.com/caolan/async) Comparison
+
+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.
+
+Let's take a look at what the most common async.js methods would look like in TaskGroup:
+
+``` javascript
+// ====================================
+// Map
+
+// Async
+async.map(['file1','file2','file3'], fs.stat, 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();
+
+
+// ====================================
+// Parallel
+
+// Async
+async.parallel([
+ function(){},
+ function(callback){callback();}
+], next);
+
+// TaskGroup
+new TaskGroup().setConfig({concurrency:0}).once('complete',next)
+ .addTask(function(){})
+ .addTask(function(callback){callback();})
+ .run();
+
+
+// ====================================
+// Series
+
+// Async
+async.series([
+ function(){},
+ function(callback){callback();}
+], next);
+
+// TaskGroup
+new TaskGroup().once('complete',next)
+ .addTask(function(){})
+ .addTask(function(callback){callback();})
+ .run();
+```
+
+
## History
You can discover the history inside the [History.md](https://github.com/bevry/taskgroup/blob/master/History.md#files) file

0 comments on commit 8b6f301

Please sign in to comment.
Something went wrong with that request. Please try again.