capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.08k stars 185 forks source link

feat: [#1468] Add AbortSignal.any() static method #1469

Open ezzatron opened 1 week ago

ezzatron commented 1 week ago

This PR adds the AbortSignal.any() static method.

This method is extremely useful for combining multiple signals together. An example would be adding a timeout to a manually aborted signal:

const timeout = AbortSignal.timeout(10000);
const controller = new AbortController();

const signal = AbortSignal.any([timeout, controller.signal]);

// Will abort after 10 seconds, or when controller.abort() is called
await fetch("https://example.org/, { signal });