From 82fe0504658db189a59090a95e1a9a1b4011a56e Mon Sep 17 00:00:00 2001 From: Chemi Atlow Date: Thu, 18 May 2023 11:11:07 +0300 Subject: [PATCH 1/2] lib: implement AbortSignal.any() PR-URL: https://github.com/nodejs/node/pull/47821 Fixes: https://github.com/nodejs/node/issues/47811 Refs: https://github.com/whatwg/dom/pull/1152 Reviewed-By: Antoine du Hamel Reviewed-By: Moshe Atlow Reviewed-By: Benjamin Gruenbaum --- doc/api/globals.md | 13 ++ lib/internal/abort_controller.js | 79 ++++++-- lib/internal/validators.js | 21 ++ test/common/wpt.js | 10 +- test/common/wpt/worker.js | 9 + test/fixtures/wpt/README.md | 2 +- .../wpt/dom/abort/abort-signal-any.any.js | 4 + .../abort/resources/abort-signal-any-tests.js | 185 ++++++++++++++++++ test/fixtures/wpt/versions.json | 2 +- test/parallel/test-abortsignal-any.mjs | 104 ++++++++++ 10 files changed, 410 insertions(+), 19 deletions(-) create mode 100644 test/fixtures/wpt/dom/abort/abort-signal-any.any.js create mode 100644 test/fixtures/wpt/dom/abort/resources/abort-signal-any-tests.js create mode 100644 test/parallel/test-abortsignal-any.mjs diff --git a/doc/api/globals.md b/doc/api/globals.md index eb3531173f47d4..7b6de36a192ebc 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -121,6 +121,18 @@ added: Returns a new `AbortSignal` which will be aborted in `delay` milliseconds. +#### Static method: `AbortSignal.any(signals)` + + + +* `signals` {AbortSignal\[]} The `AbortSignal`s of which to compose a new `AbortSignal`. + +Returns a new `AbortSignal` which will be aborted if any of the provided +signals are aborted. Its [`abortSignal.reason`][] will be set to whichever +one of the `signals` caused it to be aborted. + #### Event: `'abort'`