@@ -31,7 +31,7 @@ async.map(['file1','file2','file3'], fs.stat, function(err, results){
3131 // results is now an array of stats for each file
3232});
3333
34- async .filter ([' file1' ,' file2' ,' file3' ], fs .exists , function (results ){
34+ async .filter ([' file1' ,' file2' ,' file3' ], fs .access , function (err , results ){
3535 // results now equals an array of the existing files
3636});
3737
@@ -62,12 +62,12 @@ This can also arise by accident if you callback early in certain cases:
6262``` js
6363async .eachSeries (hugeArray, function iterator (item , callback ) {
6464 if (inCache (item)) {
65- callback (null , cache[item]); // if many items are cached, you'll overflow
65+ callback (null , cache[item]); // if many items are cached, you'll overflow
6666 } else {
6767 doSomeIO (item, callback);
6868 }
69- }, function done () {
70- // ...
69+ }, function done () {
70+ // ...
7171});
7272```
7373
@@ -470,25 +470,22 @@ async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){
470470__Alias:__ ` select`
471471
472472Returns a new array of all the values in ` arr` which pass an async truth test.
473- _The callback for each ` iterator` call only accepts a single argument of ` true ` or
474- ` false ` ; it does not accept an error argument first!_ This is in-line with the
475- way node libraries work with truth tests like ` fs .exists ` . This operation is
476- performed in parallel, but the results array will be in the same order as the
477- original.
473+ This operation is performed in parallel,
474+ but the results array will be in the same order as the original.
478475
479476__Arguments__
480477
481478* ` arr` - An array to iterate over.
482479* ` iterator (item, callback)` - A truth test to apply to each item in ` arr` .
483- The ` iterator` is passed a ` callback (truthValue)` , which must be called with a
480+ The ` iterator` is passed a ` callback (err, truthValue)` , which must be called with a
484481 boolean argument once it has completed.
485- * ` callback (results)` - *Optional* A callback which is called after all the ` iterator`
482+ * ` callback (err, results)` - *Optional* A callback which is called after all the ` iterator`
486483 functions have finished.
487484
488485__Example__
489486
490487` ` ` js
491- async .filter ([' file1' ,' file2' ,' file3' ], fs .exists , function (results ){
488+ async .filter ([' file1' ,' file2' ,' file3' ], fs .access , function (err , results ){
492489 // results now equals an array of the existing files
493490});
494491` ` `
@@ -589,17 +586,17 @@ __Arguments__
589586
590587* ` arr` - An array to iterate over.
591588* ` iterator (item, callback)` - A truth test to apply to each item in ` arr` .
592- The iterator is passed a ` callback (truthValue)` which must be called with a
593- boolean argument once it has completed. **Note: this callback does not take an error as its first argument.**
594- * ` callback (result)` - *Optional* A callback which is called as soon as any iterator returns
589+ The iterator is passed a ` callback (err, truthValue)` which must be called with a
590+ boolean argument once it has completed.
591+ * ` callback (err, result)` - *Optional* A callback which is called as soon as any iterator returns
595592 ` true ` , or after all the ` iterator` functions have finished. Result will be
596593 the first item in the array that passes the truth test (iterator) or the
597- value ` undefined ` if none passed. **Note: this callback does not take an error as its first argument.**
594+ value ` undefined ` if none passed.
598595
599596__Example__
600597
601598` ` ` js
602- async .detect ([' file1' ,' file2' ,' file3' ], fs .exists , function (result ){
599+ async .detect ([' file1' ,' file2' ,' file3' ], fs .access , function (result ){
603600 // result now equals the first file in the list that exists
604601});
605602` ` `
@@ -673,26 +670,22 @@ async.sortBy([1,9,3,5], function(x, callback){
673670__Alias:__ ` any`
674671
675672Returns ` true ` if at least one element in the ` arr` satisfies an async test.
676- _The callback for each iterator call only accepts a single argument of ` true ` or
677- ` false ` ; it does not accept an error argument first!_ This is in-line with the
678- way node libraries work with truth tests like ` fs .exists ` . Once any iterator
679- call returns ` true ` , the main ` callback` is immediately called.
673+ If any iterator call returns ` true ` , the main ` callback` is immediately called.
680674
681675__Arguments__
682676
683677* ` arr` - An array to iterate over.
684678* ` iterator (item, callback)` - A truth test to apply to each item in the array
685679 in parallel. The iterator is passed a ` callback (truthValue)` ` which must be
686680 called with a boolean argument once it has completed.
687- * ` callback(result)` - * Optional* A callback which is called as soon as any iterator returns
681+ * ` callback(err, result)` - * Optional* A callback which is called as soon as any iterator returns
688682 ` true` , or after all the iterator functions have finished . Result will be
689683 either ` true` or ` false` depending on the values of the async tests.
690684
691- ** Note: the callbacks do not take an error as their first argument.**
692685__Example__
693686
694687` ` ` js
695- async.some(['file1','file2','file3'], fs.exists , function(result){
688+ async.some(['file1','file2','file3'], fs.access , function(result){
696689 // if result is true then at least one of the files exists
697690});
698691` ` `
@@ -705,26 +698,22 @@ async.some(['file1','file2','file3'], fs.exists, function(result){
705698__Alias: __ ` all`
706699
707700Returns ` true` if every element in ` arr` satisfies an async test.
708- _The callback for each ` iterator` call only accepts a single argument of ` true` or
709- ` false` ; it does not accept an error argument first! _ This is in - line with the
710- way node libraries work with truth tests like ` fs.exists` .
701+ If any iterator call returns ` false` , the main ` callback` is immediately called.
711702
712703__Arguments__
713704
714705* ` arr` - An array to iterate over.
715706* ` iterator(item, callback)` - A truth test to apply to each item in the array
716- in parallel . The iterator is passed a ` callback(truthValue)` which must be
707+ in parallel . The iterator is passed a ` callback(err, truthValue)` which must be
717708 called with a boolean argument once it has completed.
718- * ` callback(result)` - * Optional* A callback which is called after all the ` iterator`
709+ * ` callback(err, result)` - * Optional* A callback which is called after all the ` iterator`
719710 functions have finished . Result will be either ` true` or ` false` depending on
720711 the values of the async tests.
721712
722- ** Note: the callbacks do not take an error as their first argument.**
723-
724713__Example__
725714
726715` ` ` js
727- async.every(['file1','file2','file3'], fs.exists , function(result){
716+ async.every(['file1','file2','file3'], fs.access , function(err, result){
728717 // if result is true then every file exists
729718});
730719` ` `
@@ -1721,9 +1710,9 @@ function sometimesAsync(arg, callback) {
17211710}
17221711
17231712// this has a risk of stack overflows if many results are cached in a row
1724- async .mapSeries (args, sometimesAsync, done);
1713+ async .mapSeries (args, sometimesAsync, done);
17251714
1726- // this will defer sometimesAsync's callback if necessary,
1715+ // this will defer sometimesAsync's callback if necessary,
17271716// preventing stack overflows
17281717async .mapSeries (args, async .ensureAsync (sometimesAsync), done);
17291718
0 commit comments