waitUntil
for usage outside of Service/Cloudflare Workers.
npm i wait-until-generalized
import { WaitUntilList } from 'wait-until-generalized';
const { waitUntil, waitUntilSettled } = new WaitUntilList();
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
waitUntil(delay(1000).then(() => {
console.log('Waited one second');
waitUntil(delay(1000).then(() => {
console.log('Waited another second');
}));
}));
const results = await waitUntilSettled();
results.length // -> 2