diff --git a/@vates/async-each/.USAGE.md b/@vates/async-each/.USAGE.md index 323ccabec..100b755d0 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`. The value `0` means no concurrency limit. +- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `10`. 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 2ad81ec86..93cdbe8d3 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`. The value `0` means no concurrency limit. +- `concurrency`: a number which indicates the maximum number of parallel call to `iteratee`, defaults to `10`. 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 0a291a6e1..adf3cd5c7 100644 --- a/@vates/async-each/index.js +++ b/@vates/async-each/index.js @@ -15,7 +15,7 @@ class AggregateError extends Error { * @param {(item: Item, index: number, iterable: Iterable) => Promise} iteratee * @returns {Promise} */ -exports.asyncEach = function asyncEach(iterable, iteratee, { concurrency = 1, signal, stopOnError = true } = {}) { +exports.asyncEach = function asyncEach(iterable, iteratee, { concurrency = 10, signal, stopOnError = true } = {}) { if (concurrency === 0) { concurrency = Infinity } diff --git a/@vates/async-each/index.spec.js b/@vates/async-each/index.spec.js index 26f315968..20e85e3ee 100644 --- a/@vates/async-each/index.spec.js +++ b/@vates/async-each/index.spec.js @@ -36,7 +36,7 @@ describe('asyncEach', () => { it('works', async () => { const iteratee = jest.fn(async () => {}) - await asyncEach.call(thisArg, iterable, iteratee) + await asyncEach.call(thisArg, iterable, iteratee, { concurrency: 1 }) expect(iteratee.mock.instances).toEqual(Array.from(values, () => thisArg)) expect(iteratee.mock.calls).toEqual(Array.from(values, (value, index) => [value, index, iterable])) @@ -66,7 +66,7 @@ describe('asyncEach', () => { } }) - expect(await rejectionOf(asyncEach(iterable, iteratee, { stopOnError: true }))).toBe(error) + expect(await rejectionOf(asyncEach(iterable, iteratee, { concurrency: 1, stopOnError: true }))).toBe(error) expect(iteratee).toHaveBeenCalledTimes(2) }) @@ -91,7 +91,9 @@ describe('asyncEach', () => { } }) - await expect(asyncEach(iterable, iteratee, { signal: ac.signal })).rejects.toThrow('asyncEach aborted') + await expect(asyncEach(iterable, iteratee, { concurrency: 1, signal: ac.signal })).rejects.toThrow( + 'asyncEach aborted' + ) expect(iteratee).toHaveBeenCalledTimes(2) }) }) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 0369c9bf1..0a733b1df 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -29,7 +29,7 @@ -- @vates/async-each minor +- @vates/async-each major - xo-web minor