[Pkg-javascript-commits] [node-async] 355/480: Update async.auto example in README.md

Jonas Smedegaard js at moszumanska.debian.org
Fri May 2 08:58:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository node-async.

commit 908cf761de81fdfcc7d57f2b0a011229a40b1795
Author: josher19 <josher19 at gmail.com>
Date:   Thu Oct 24 12:10:50 2013 +0800

    Update async.auto example in README.md
    
    async.auto does not actually run (because callbacks not called) and does not illustrate main features of async.auto. Updated to use callback and console.log results.
---
 README.md | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index aff0040..bd7ff62 100644
--- a/README.md
+++ b/README.md
@@ -1105,21 +1105,31 @@ __Example__
 ```js
 async.auto({
     get_data: function(callback){
+        console.log('in get_data');
         // async code to get some data
+        callback(null, 'data', 'converted to array');
     },
     make_folder: function(callback){
+        console.log('in make_folder');
         // async code to create a directory to store a file in
         // this is run at the same time as getting the data
+        callback(null, 'folder');
     },
-    write_file: ['get_data', 'make_folder', function(callback){
+    write_file: ['get_data', 'make_folder', function(callback, results){
+        console.log('in write_file', JSON.stringify(results));
         // once there is some data and the directory exists,
         // write the data to a file in the directory
-        callback(null, filename);
+        callback(null, 'filename');
     }],
     email_link: ['write_file', function(callback, results){
+        console.log('in email_link', JSON.stringify(results));
         // once the file is written let's email a link to it...
         // results.write_file contains the filename returned by write_file.
+        callback(null, {'file':results.write_file, 'email':'user at example.com'});
     }]
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('results = ', results);
 });
 ```
 
@@ -1129,21 +1139,30 @@ series functions would look like this:
 ```js
 async.parallel([
     function(callback){
+        console.log('in get_data');
         // async code to get some data
+        callback(null, 'data', 'converted to array');
     },
     function(callback){
+        console.log('in make_folder');
         // async code to create a directory to store a file in
         // this is run at the same time as getting the data
+        callback(null, 'folder');
     }
 ],
 function(err, results){
     async.series([
         function(callback){
+            console.log('in write_file', JSON.stringify(results));
             // once there is some data and the directory exists,
             // write the data to a file in the directory
+            results.push('filename');
+            callback(null);
         },
         function(callback){
+            console.log('in email_link', JSON.stringify(results));
             // once the file is written let's email a link to it...
+            callback(null, {'file':results.pop(), 'email':'user at example.com'});
         }
     ]);
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-async.git



More information about the Pkg-javascript-commits mailing list