File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
packages/abort-signal-any/src Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,12 @@ export function abortSignalAny(iterable: Iterable<AbortSignal>) {
14
14
15
15
// otherwise ready a controller and listen for abort signals
16
16
const ctrl = new AbortController ( ) ;
17
- function abort ( this : AbortSignal ) {
18
- ctrl . abort (
19
- // TODO: we use Object(this) because `this` is undefined for signals coming from whatwg-node (ServerAdapterRequestAbortSignal)
20
- Object ( this ) . reason ,
21
- ) ;
17
+ function abort ( this : AbortSignal , event : Event ) {
18
+ if ( this instanceof AbortSignal ) {
19
+ ctrl . abort ( this . reason ) ;
20
+ } else {
21
+ ctrl . abort ( ( event . target as AbortSignal ) . reason ) ;
22
+ }
22
23
// do cleanup
23
24
for ( const signal of signals ) {
24
25
signal . removeEventListener ( 'abort' , abort ) ;
You can’t perform that action at this time.
0 commit comments