File tree 3 files changed +3
-34
lines changed
3 files changed +3
-34
lines changed Original file line number Diff line number Diff line change 12
12
node-version :
13
13
- 20
14
14
- 18
15
- - 16
16
15
steps :
17
16
- uses : actions/checkout@v3
18
17
- uses : actions/setup-node@v3
Original file line number Diff line number Diff line change 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
-
31
1
export default async function pMap (
32
2
iterable ,
33
3
mapper ,
@@ -68,11 +38,11 @@ export default async function pMap(
68
38
69
39
if ( signal ) {
70
40
if ( signal . aborted ) {
71
- reject ( getAbortedReason ( signal ) ) ;
41
+ reject ( signal . reason ) ;
72
42
}
73
43
74
44
signal . addEventListener ( 'abort' , ( ) => {
75
- reject ( getAbortedReason ( signal ) ) ;
45
+ reject ( signal . reason ) ;
76
46
} ) ;
77
47
}
78
48
Original file line number Diff line number Diff line change 13
13
"type" : " module" ,
14
14
"exports" : " ./index.js" ,
15
15
"engines" : {
16
- "node" : " >=16 "
16
+ "node" : " >=18 "
17
17
},
18
18
"scripts" : {
19
19
"test" : " xo && ava && tsd"
You can’t perform that action at this time.
0 commit comments