diff --git a/@vates/async-each/.USAGE.md b/@vates/async-each/.USAGE.md index 8dabffc45..323ccabec 100644 --- a/@vates/async-each/.USAGE.md +++ b/@vates/async-each/.USAGE.md @@ -14,7 +14,7 @@ Returns a promise wich rejects as soon as a call to `iteratee` throws or a promi `opts` is an object that can contains the following options: -- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `1` +- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `1`. The value `0` means no concurrency limit. - `signal`: an abort signal to stop the iteration - `stopOnError`: wether to stop iteration of first error, or wait for all calls to finish and throw an `AggregateError`, defaults to `true` diff --git a/@vates/async-each/README.md b/@vates/async-each/README.md index 7b56ab151..2ad81ec86 100644 --- a/@vates/async-each/README.md +++ b/@vates/async-each/README.md @@ -32,7 +32,7 @@ Returns a promise wich rejects as soon as a call to `iteratee` throws or a promi `opts` is an object that can contains the following options: -- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `1` +- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `1`. The value `0` means no concurrency limit. - `signal`: an abort signal to stop the iteration - `stopOnError`: wether to stop iteration of first error, or wait for all calls to finish and throw an `AggregateError`, defaults to `true` diff --git a/@vates/async-each/index.js b/@vates/async-each/index.js index c95af2d8e..61ff415be 100644 --- a/@vates/async-each/index.js +++ b/@vates/async-each/index.js @@ -10,6 +10,9 @@ class AggregateError extends Error { } exports.asyncEach = function asyncEach(iterable, iteratee, { concurrency = 1, signal, stopOnError = true } = {}) { + if (concurrency === 0) { + concurrency = Infinity + } return new Promise((resolve, reject) => { const it = (iterable[Symbol.iterator] || iterable[Symbol.asyncIterator]).call(iterable) const errors = [] diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index ff06bf794..0369c9bf1 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -29,6 +29,7 @@ +- @vates/async-each minor - xo-web minor