[whatwg/dom] Creating an already aborted AbortController (#959)

In Node.js, we have had a couple of use cases pop up recently with the need to mark an `AbortController` already aborted immediately after creation. Typically, this would be done as: `const ac = new AbortController(); ac.abort(); return ac;`.

It would be helpful to have a utility that makes this easier... 

Either:

```js
const ac = new AbortController({ aborted: true });
```

or

```js
const ac = AbortController.aborted();
```

The `abort` event would never trigger on such objects, which is perfectly fine. We already tell users to check the `aborted` property before attaching `abort` listeners.

If the idea seems reasonable, I can work up a PR with the change. I would just need to know which approach (init options vs. static factory function) is preferred.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/959

Received on Tuesday, 9 March 2021 17:49:27 UTC