mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
lib: improve AbortController creation duration
PR-URL: https://github.com/nodejs/node/pull/45525 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
16643dbb19
commit
5745bcbb41
1 file changed
+3
-2
@@ -309,12 +309,13 @@ function abortSignal(signal, reason) {
|
||||
}
|
||||
|
||||
class AbortController {
|
||||
#signal = createAbortSignal();
|
||||
#signal;
|
||||
|
||||
/**
|
||||
* @type {AbortSignal}
|
||||
*/
|
||||
get signal() {
|
||||
this.#signal ??= createAbortSignal();
|
||||
return this.#signal;
|
||||
}
|
||||
|
||||
@@ -322,7 +323,7 @@ class AbortController {
|
||||
* @param {any} reason
|
||||
*/
|
||||
abort(reason = new DOMException('This operation was aborted', 'AbortError')) {
|
||||
abortSignal(this.#signal, reason);
|
||||
abortSignal(this.#signal ??= createAbortSignal(), reason);
|
||||
}
|
||||
|
||||
[customInspectSymbol](depth, options) {
|
||||
|
||||
Reference in new issue
Block a user