Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working version of mapLimit and parallelLimit #205

Merged
merged 4 commits into from
Jan 31, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,35 @@ series. The next iterator is only called once the current one has completed
processing. The results array will be in the same order as the original.


---------------------------------------

<a name="mapLimit" />
### mapLimit(arr, limit, iterator, callback)

The same as map only the iterator is applied to batches of items in the
array, in series. The next batch of iterators is only called once the current
one has completed processing.

__Arguments__

* arr - An array to iterate over.
* limit - How many items should be in each batch.
* iterator(item, callback) - A function to apply to each item in the array.
The iterator is passed a callback which must be called once it has completed.
If no error has occured, the callback should be run without arguments or
with an explicit null argument.
* callback(err, results) - A callback which is called after all the iterator
functions have finished, or an error has occurred. Results is an array of the
transformed items from the original array.

__Example__

```js
async.map(['file1','file2','file3'], 1, fs.stat, function(err, results){
// results is now an array of stats for each file
});
```

---------------------------------------

<a name="filter" />
Expand Down Expand Up @@ -628,6 +657,24 @@ function(err, results) {
});
```

---------------------------------------

<a name="parallel" />
### parallelLimit(tasks, limit, [callback])

The same as parallel only the tasks are executed in parallel with a maximum of "limit"
tasks executing at any time.

__Arguments__

* tasks - An array or object containing functions to run, each function is passed a
callback it must call on completion.
* limit - The maximum number of tasks to run at any time.
* callback(err, results) - An optional callback to run once all the functions
have completed. This function gets an array of all the arguments passed to
the callbacks used in the array.


---------------------------------------

<a name="whilst" />
Expand Down
2 changes: 1 addition & 1 deletion dist/async.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading