Whoever resolves first, wins! πββοΈ
Teeny-tiny wrapper around Promise.race that adds a timeout.
npm i @rbnlffl/raceimport race from "@rbnlffl/race";
// race a single promise against a timeout
const result = await race(someAsyncOperation(), 5000);
// race multiple promises: resolves with whichever settles first
const first = await race([fetchFromPrimary(), fetchFromFallback()], 5000);If the timeout expires before any promise settles, race rejects with an Error:
Error: Not settled after 5000ms!