-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,12 +50,8 @@ function parseParams(func) { | |
* arguments of those parameters. | ||
* @param {Function} [callback] - An optional callback which is called when all | ||
* the tasks have been completed. It receives the `err` argument if any `tasks` | ||
* pass an error to their callback. The remaining parameters are task names | ||
* whose results you are interested in. This callback will only be called when | ||
* all tasks have finished or an error has occurred, and so do not specify | ||
* dependencies in the same way as `tasks` do. If an error occurs, no further | ||
* `tasks` will be performed, and `results` will only be valid for those tasks | ||
* which managed to complete. Invoked with (err, [results...]). | ||
* pass an error to their callback, and a `results` object with any completed | ||
* task results, similar to `auto`. | ||
* @example | ||
* | ||
* // The example from `auto` can be rewritten as follows: | ||
|
@@ -79,17 +75,16 @@ function parseParams(func) { | |
* // write_file contains the filename returned by write_file. | ||
* callback(null, {'file':write_file, 'email':'[email protected]'}); | ||
* } | ||
* }, function(err, email_link) { | ||
* }, function(err, results) { | ||
* console.log('err = ', err); | ||
* console.log('email_link = ', email_link); | ||
* console.log('email_link = ', results.email_link); | ||
* }); | ||
* | ||
* // If you are using a JS minifier that mangles parameter names, `autoInject` | ||
* // will not work with plain functions, since the parameter names will be | ||
* // collapsed to a single letter identifier. To work around this, you can | ||
* // explicitly specify the names of the parameters your task function needs | ||
* // in an array, similar to Angular.js dependency injection. The final | ||
* // results callback can be provided as an array in the same way. | ||
* // in an array, similar to Angular.js dependency injection. | ||
* | ||
* // This still has an advantage over plain `auto`, since the results a task | ||
* // depends on are still spread into arguments. | ||
|
@@ -102,10 +97,10 @@ function parseParams(func) { | |
* callback(null, {'file':write_file, 'email':'[email protected]'}); | ||
* }] | ||
* //... | ||
* }, ['email_link', function(err, email_link) { | ||
* }, function(err, results) { | ||
* console.log('err = ', err); | ||
* console.log('email_link = ', email_link); | ||
* }]); | ||
* console.log('email_link = ', results.email_link); | ||
* }); | ||
*/ | ||
export default function autoInject(tasks, callback) { | ||
var newTasks = {}; | ||
|