import pTimeout from "https://deno.land/x/[email protected]/mod.ts"
const delayedPromise = new Promise(resolve => setTimeout(resolve, 500))
await pTimeout({
promise: delayedPromise,
milliseconds: 50,
})
// => [TimeoutError: Promise timed out after 50 milliseconds]
See https://doc.deno.land/https/deno.land/x/[email protected]/mod.ts
- HUGE thanks to @sindresorhus -- this repository is mostly his code, modified to work with Deno
- Promise Timeout is licensed under the MIT license.
- Code is adapted from Sindre's p-timeout for node (also under the MIT license)