Compare commits

..

No commits in common. "b193312ed6b24565bcc38d4b915db294f8c98774" and "0c2692f9fb5de33fe2cc0c3f6a0a1fab74a36604" have entirely different histories.

2 changed files with 6 additions and 14 deletions

View File

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

View File

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