Skip to content

Commit

Permalink
fixup! lib: add abortSignal.throwIfAborted()
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Nov 24, 2021
1 parent 02cc0ee commit f909d80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/abort_controller.js
Expand Up @@ -90,7 +90,7 @@ class AbortSignal extends EventTarget {
* @returns {AbortSignal}
*/
static abort(
reason = new DOMException('This operation was aborted', 'AbortError')) {
reason = new DOMException('This operation was aborted', 'AbortError')) {
return createAbortSignal(true, reason);
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-abortcontroller.js
Expand Up @@ -169,4 +169,8 @@ const { ok, strictEqual, throws } = require('assert');
{
// Test abortSignal.throwIfAborted()
throws(() => AbortSignal.abort().throwIfAborted(), { code: 20 });

// Does not throw because it's not aborted.
const ac = new AbortController();
ac.signal.throwIfAborted();
}

0 comments on commit f909d80

Please sign in to comment.