diff options
author | Bei Jia <bjia927@gmail.com> | 2014-04-09 10:59:34 -0500 |
---|---|---|
committer | Bei Jia <bjia927@gmail.com> | 2014-04-09 10:59:34 -0500 |
commit | 8a5ebb1132f70fe19747cff8f371bd92b6a9a75b (patch) | |
tree | 584a4adf3535fb466e54449fb06387247d6c310d | |
parent | 440c2376376926f0d851f942b4b8ad53427f2d86 (diff) | |
download | async-8a5ebb1132f70fe19747cff8f371bd92b6a9a75b.tar.gz |
Update README.md
Fixing example on .each
-rw-r--r-- | README.md | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -199,26 +199,23 @@ async.each(openFiles, saveFile, function(err){ ``` ```js -// assuming openFiles is an array of file names and saveFile is a function -// to save the modified contents of that file: +// assuming openFiles is an array of file names async.each(openFiles, function( file, callback) { // Perform operation on file here. console.log('Processing file ' + file); - callback(); - + if( file.length > 32 ) { console.log('This file name is too long'); callback('File name too long'); - - return; } else { - console.log('File saved'); + // Do work To process file here + console.log('File processed'); callback(); } }, function(err){ - // if any of the saves produced an error, err would equal that error + // if any of the file processing produced an error, err would equal that error if( err ) { // One of the iterations produced an error. // All processing will now stop. |