Skip to content

Commit 9be77a6

Browse files
authored
Merge branch 'sindresorhus:main' into iterable
2 parents 63d99e0 + 136b08a commit 9be77a6

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed

.github/workflows/main.yml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
node-version:
1313
- 20
1414
- 18
15-
- 16
1615
steps:
1716
- uses: actions/checkout@v3
1817
- uses: actions/setup-node@v3

index.js

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
/**
2-
An error to be thrown when the request is aborted by AbortController.
3-
DOMException is thrown instead of this Error when DOMException is available.
4-
*/
5-
export class AbortError extends Error {
6-
constructor(message) {
7-
super();
8-
this.name = 'AbortError';
9-
this.message = message;
10-
}
11-
}
12-
13-
/**
14-
TODO: Remove AbortError and just throw DOMException when targeting Node 18.
15-
*/
16-
const getDOMException = errorMessage => globalThis.DOMException === undefined
17-
? new AbortError(errorMessage)
18-
: new DOMException(errorMessage);
19-
20-
/**
21-
TODO: Remove below function and just 'reject(signal.reason)' when targeting Node 18.
22-
*/
23-
const getAbortedReason = signal => {
24-
const reason = signal.reason === undefined
25-
? getDOMException('This operation was aborted.')
26-
: signal.reason;
27-
28-
return reason instanceof Error ? reason : getDOMException(reason);
29-
};
30-
311
export default async function pMap(
322
iterable,
333
mapper,
@@ -68,11 +38,11 @@ export default async function pMap(
6838

6939
if (signal) {
7040
if (signal.aborted) {
71-
reject(getAbortedReason(signal));
41+
reject(signal.reason);
7242
}
7343

7444
signal.addEventListener('abort', () => {
75-
reject(getAbortedReason(signal));
45+
reject(signal.reason);
7646
});
7747
}
7848

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "module",
1414
"exports": "./index.js",
1515
"engines": {
16-
"node": ">=16"
16+
"node": ">=18"
1717
},
1818
"scripts": {
1919
"test": "xo && ava && tsd"

0 commit comments

Comments
 (0)