Skip to content

Commit

Permalink
comment preferred vs legacy control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Jun 18, 2024
1 parent 28c0ea5 commit 96e07c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/fetch-http-handler/src/fetch-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ export class FetchHttpHandler implements HttpHandler<FetchHttpHandlerConfig> {
reject(abortError);
};
if (typeof (abortSignal as AbortSignal).addEventListener === "function") {
// preferred.
(abortSignal as AbortSignal).addEventListener("abort", onAbort);
} else {
// backwards compatibility
abortSignal.onabort = onAbort;
}
})
Expand Down
2 changes: 2 additions & 0 deletions packages/node-http-handler/src/node-http-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ export class NodeHttpHandler implements HttpHandler<NodeHttpHandlerOptions> {
reject(abortError);
};
if (typeof (abortSignal as AbortSignal).addEventListener === "function") {
// preferred.
(abortSignal as AbortSignal).addEventListener("abort", onAbort);
} else {
// backwards compatibility
abortSignal.onabort = onAbort;
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/node-http-handler/src/node-http2-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ export class NodeHttp2Handler implements HttpHandler<NodeHttp2HandlerOptions> {
rejectWithDestroy(abortError);
};
if (typeof (abortSignal as AbortSignal).addEventListener === "function") {
// preferred.
(abortSignal as AbortSignal).addEventListener("abort", onAbort);
} else {
// backwards compatibility
abortSignal.onabort = onAbort;
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/util-waiter/src/createWaiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const abortTimeout = async (abortSignal: AbortSignal | DeprecatedAbortSignal): P
return new Promise((resolve) => {
const onAbort = () => resolve({ state: WaiterState.ABORTED });
if (typeof (abortSignal as AbortSignal).addEventListener === "function") {
// preferred.
(abortSignal as AbortSignal).addEventListener("abort", onAbort);
} else {
// backwards compatibility
abortSignal.onabort = onAbort;
}
});
Expand Down

0 comments on commit 96e07c7

Please sign in to comment.