summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBei Jia <bjia927@gmail.com>2014-04-09 10:59:34 -0500
committerBei Jia <bjia927@gmail.com>2014-04-09 10:59:34 -0500
commit8a5ebb1132f70fe19747cff8f371bd92b6a9a75b (patch)
tree584a4adf3535fb466e54449fb06387247d6c310d
parent440c2376376926f0d851f942b4b8ad53427f2d86 (diff)
downloadasync-8a5ebb1132f70fe19747cff8f371bd92b6a9a75b.tar.gz
Update README.md
Fixing example on .each
-rw-r--r--README.md13
1 files changed, 5 insertions, 8 deletions
diff --git a/README.md b/README.md
index 1835942..dd40026 100644
--- a/README.md
+++ b/README.md
@@ -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.