Compare commits
2 Commits
0c2692f9fb
...
b193312ed6
Author | SHA1 | Date |
---|---|---|
AJ ONeal | b193312ed6 | |
AJ ONeal | 81333f4c47 |
18
README.md
18
README.md
|
@ -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)**:
|
||||
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue