Skip to content

Commit

Permalink
less params in each.async
Browse files Browse the repository at this point in the history
  • Loading branch information
E.Azer Koçulu committed Aug 19, 2012
1 parent 8b54a10 commit 4db1708
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion lib/functools.js
Expand Up @@ -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));
};
Expand Down
2 changes: 1 addition & 1 deletion 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"],
Expand Down
8 changes: 3 additions & 5 deletions test/main.js
Expand Up @@ -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();

Expand All @@ -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 );

Expand Down

0 comments on commit 4db1708

Please sign in to comment.