Promise Timeout
Timeout a promise after a specified amount of time. Deno port of sindresorhus’s p-timeout for node
Usage
import pTimeout from "https://deno.land/x/p_timeout@1.0.2/mod.ts"
const delayedPromise = new Promise(resolve => setTimeout(resolve, 500))
await pTimeout({
promise: delayedPromise,
milliseconds: 50,
})
// => [TimeoutError: Promise timed out after 50 milliseconds]
API
See https://doc.deno.land/https/deno.land/x/p_timeout@1.0.2/mod.ts
Supporters
- HUGE thanks to @sindresorhus – this repository is mostly his code, modified to work with Deno
Related
License
- Promise Timeout is licensed under the MIT license.
- Code is adapted from Sindre’s p-timeout for node (also under the MIT license)