Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

less params in each.async

  • Loading branch information...
commit 4db170841f3ff6fc139e14b9e6fdfd5851b324b7 1 parent 8b54a10
@azer authored
Showing with 9 additions and 11 deletions.
  1. +4 −4 README.md
  2. +1 −1  lib/functools.js
  3. +1 −1  package.json
  4. +3 −5 test/main.js
View
8 README.md
@@ -149,15 +149,15 @@ each(function(el,ind,list){ console.assert( el == list[ind] ); }, [3, 1, 4]);
```
<a name="each.async" />
-## each(*function*,*iterable*,*callback*)
+## each.async(*function*,*iterable*,*callback*)
Call async *function* once for each element in *iterable*, and *callback* after iteration.
```javascript
-> function uploadFile(filename, index, files, callback){
- console.log('Uploading ', filename);
- callback();
+> function uploadFile(filename, callback){
+ console.log('Uploading ', filename);
+ callback();
}
> each.async(uploadFile, [ '/docs/intro', '/docs/body', '/docs/outro' ], function(error){
View
2  lib/functools.js
@@ -109,7 +109,7 @@ var functools = (function(undefined){
return;
}
- fn(iterable[i], i, iterable, partial(next, [i+1]));
+ fn(iterable[i], partial(next, [i+1]));
}(0));
};
View
2  package.json
@@ -1,6 +1,6 @@
{
"name":"functools",
- "version":"1.3.0",
+ "version":"1.4.0",
"description":"A minimal library of functional operations",
"author":"Azer Koculu <azer@kodfabrik.com>",
"keywords":["functional","fp"],
View
8 test/main.js
@@ -103,11 +103,9 @@ function test_each_async(callback){
var range = [1, 2, 3, 4, 5],
serial = 0;
- functools.each.async(function(el, ind, seq, callback){
+ functools.each.async(function(el, callback){
- assert.equal(seq,range);
- assert.equal(ind,serial++);
- assert.ok(ind<seq.length);
+ assert.equal(el,range[serial++]);
callback();
@@ -122,7 +120,7 @@ function test_each_async_error(callback){
var range = [1, 2, 3, 4, 5],
serial = 0;
- functools.each.async(function(el, ind, seq, callback){
+ functools.each.async(function(el, callback){
callback( ++serial == 2 ? new Error('foobar') : undefined );
Please sign in to comment.
Something went wrong with that request. Please try again.