From 049be42f38226d2bba5cdba9a8a03e15e0e8bad4 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 24 Nov 2021 07:28:30 -0800 Subject: [PATCH] lib: add abortSignal.throwIfAborted() Refs: https://github.com/whatwg/dom/pull/1034 Signed-off-by: James M Snell --- doc/api/globals.md | 8 ++++++++ lib/internal/abort_controller.js | 11 +++++++++-- test/parallel/test-abortcontroller.js | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/api/globals.md b/doc/api/globals.md index 3e47237714f306..9df487a786ac1e 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -191,6 +191,14 @@ ac.abort(new Error('boom!')); console.log(ac.signal.reason); // Error('boom!'); ``` +#### `abortSignal.throwIfAborted()` + + + +If `abortSignal.aborted` is `true`, throws `abortSignal.reason`. + ## Class: `Buffer`