update README

This commit is contained in:
AJ ONeal 2019-06-13 17:51:53 -06:00
parent 0c2692f9fb
commit 81333f4c47
1 changed files with 13 additions and 5 deletions

View File

@ -3,13 +3,17 @@
Like calling `map()` and resolving with `Promise.all()`,
but handling a bounded number of items at any given time.
## Install
Want to read about it?
- [Batching async requests in < 50 lines of VanillaJS](https://coolaj86.com/articles/batching-async-requests-50-lines-of-vanilla-js/)
# Install
```bash
npm install --save batchasync
```
## Usage
# Usage
```js
// Browsers
@ -35,10 +39,14 @@ batchAsync(batchSize, things, doStuff).then(function(results) {
});
```
### Returning 'undefined'
## A note on 'undefined'
Returning `undefined` will cause an exception to be thrown
(because it looks like a skipped promise). Return `null` instead.
Returning `undefined` will cause an exception to be thrown,
and the Promise to be rejected.
This is on purpose - because `undefined` is indistinguishable from a skipped Promise.
Return `null` instead.
**Example (bad)**: