Skip to content

Commit

Permalink
tabs to spaces in examples and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianc committed Nov 18, 2011
1 parent e9e80b6 commit 5532606
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions README.md
Expand Up @@ -18,7 +18,7 @@ new FnQueue(functionsList[, callback, concurrencyLevel, isStopped]);
##Parameters

1. `functionsList` __(Object)__ a list of Functions. Each function can declare implicit dependencies as arguments and assume you provide a single callback as the last argument.
2. `callback` __(Function(err, data))__ the complete callback in the conventional form of `function (err, data){ ... }`
2. `callback` __(Function(err, data))__ the complete callback in the conventional form of `function (err, data) { ... }`
3. `concurrencyLevel` __(Number/String: defaults to 'auto')__ the concurrency level of the chain execution, can be `'auto'` or `N* = { 1, 2, ... }`
4. `isStopped` __(Boolean: defaults to false)__ if true you must call the start method in order to execute the function list.

Expand Down Expand Up @@ -55,43 +55,44 @@ Example:

```javascript
new FnQueue({
// this will wait for 'processSomething' and 'searchSomething' and will be called with the respective results
funnyStuff: function(processSomething, searchSomething, callback){
// do something silly
callback(null, 'ciao!');
},
// this will be called instantly
searchSomething: function(callback){
// do something with database
callback(err, results);
},
// this will wait 'searchSomething'
update: function(searchSomething, callback){
// change values inside results and save to db
callback(err); // no needs to return values
},
// this will wait 'searchSomething'
processSomething: function(searchSomething, callback){
var start = new Date().getTime();
// do something slow
var elapsedTime = new Date().getTime() - start;
callback(err, elapsedTime);
}]
},function(err, data){

if(err)
throw err;

console.log(data.searchSomething); // results
console.log(data.update); // undefined
console.log(data.processSomething); // elapsedTime
console.log(data.funnyStuff); // 'ciao!'
// this will wait for 'processSomething' and 'searchSomething' and will be called with the respective results
funnyStuff: function (processSomething, searchSomething, callback) {
// do something silly
callback(null, 'ciao!');
},
// this will be called instantly
searchSomething: function (callback) {
// do something with database
callback(err, results);
},
// this will wait 'searchSomething'
update: function (searchSomething, callback) {
// change values inside results and save to db
callback(err); // no needs to return values
},
// this will wait 'searchSomething'
processSomething: function (searchSomething, callback) {
var start = new Date().getTime();
// do something slow
var elapsedTime = new Date().getTime() - start;
callback(err, elapsedTime);
}]
}, function (err, data) {

if (err) {
throw err;
}

console.log(data.searchSomething); // results
console.log(data.update); // undefined
console.log(data.processSomething); // elapsedTime
console.log(data.funnyStuff); // 'ciao!'
}, 1);
```

##Introspection profiling results

Profiling results are pretty good, Function.toString() took up __~2 seconds__ every __1 Million__ of executions.
Profiling results are pretty good, Function.toString() took up __2~ seconds__ every __1 Million__ of executions.

Lines of code time (ms) Platform
---------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 5532606

Please sign in to comment.