Compare commits

...

2 Commits

Author SHA1 Message Date
AJ ONeal b193312ed6 bump v1.0.2 2019-06-13 17:52:05 -06:00
AJ ONeal 81333f4c47 update README 2019-06-13 17:51:53 -06:00
2 changed files with 14 additions and 6 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)**:

View File

@ -1,6 +1,6 @@
{
"name": "batchasync",
"version": "1.0.1",
"version": "1.0.2",
"description": "Like forEachAsync, or Promise.all(), but handling a bounded number of items at any given time.",
"main": "batchasync.js",
"scripts": {