diff --git a/README.md b/README.md index fdcf29e..caca6fc 100644 --- a/README.md +++ b/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)**: