Skip to content

Commit

Permalink
Drop aggregate-error dependency and require Node.js 16 (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
furudean and sindresorhus committed Apr 22, 2023
1 parent a5faf42 commit df88787
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Expand Up @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 20
- 18
- 16
- 14
- 12
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
4 changes: 1 addition & 3 deletions index.js
@@ -1,5 +1,3 @@
import AggregateError from 'aggregate-error';

/**
An error to be thrown when the request is aborted by AbortController.
DOMException is thrown instead of this Error when DOMException is available.
Expand Down Expand Up @@ -99,7 +97,7 @@ export default async function pMap(

if (resolvingCount === 0 && !isResolved) {
if (!stopOnError && errors.length > 0) {
reject(new AggregateError(errors));
reject(new AggregateError(errors)); // eslint-disable-line unicorn/error-message
return;
}

Expand Down
5 changes: 1 addition & 4 deletions package.json
Expand Up @@ -13,7 +13,7 @@
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
"node": ">=16"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -40,9 +40,6 @@
"parallel",
"bluebird"
],
"dependencies": {
"aggregate-error": "^4.0.0"
},
"devDependencies": {
"ava": "^4.1.0",
"delay": "^5.0.0",
Expand Down
9 changes: 4 additions & 5 deletions test.js
Expand Up @@ -3,7 +3,6 @@ import delay from 'delay';
import inRange from 'in-range';
import timeSpan from 'time-span';
import randomInt from 'random-int';
import AggregateError from 'aggregate-error';
import pMap, {pMapSkip} from './index.js';

const sharedInput = [
Expand Down Expand Up @@ -143,8 +142,8 @@ test('immediately rejects when stopOnError is true', async t => {

test('aggregate errors when stopOnError is false', async t => {
await t.notThrowsAsync(pMap(sharedInput, mapper, {concurrency: 1, stopOnError: false}));
await t.throwsAsync(pMap(errorInput1, mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: /foo(.|\n)*bar/});
await t.throwsAsync(pMap(errorInput2, mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: /bar(.|\n)*foo/});
await t.throwsAsync(pMap(errorInput1, mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: ''});
await t.throwsAsync(pMap(errorInput2, mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: ''});
});

test('pMapSkip', async t => {
Expand Down Expand Up @@ -279,8 +278,8 @@ test('asyncIterator - immediately rejects when stopOnError is true', async t =>

test('asyncIterator - aggregate errors when stopOnError is false', async t => {
await t.notThrowsAsync(pMap(new AsyncTestData(sharedInput), mapper, {concurrency: 1, stopOnError: false}));
await t.throwsAsync(pMap(new AsyncTestData(errorInput1), mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: /foo(.|\n)*bar/});
await t.throwsAsync(pMap(new AsyncTestData(errorInput2), mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: /bar(.|\n)*foo/});
await t.throwsAsync(pMap(new AsyncTestData(errorInput1), mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: ''});
await t.throwsAsync(pMap(new AsyncTestData(errorInput2), mapper, {concurrency: 1, stopOnError: false}), {instanceOf: AggregateError, message: ''});
});

test('asyncIterator - pMapSkip', async t => {
Expand Down

0 comments on commit df88787

Please sign in to comment.