People standing in Timeout illustration

Promise Timeout

Timeout a promise after a specified amount of time. Deno port of sindresorhus's p-timeout for node

build status language code size issues license version

View on deno.land




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

Stargazers repo roster for @KhushrajRathod/pTimeout

Forkers repo roster for @KhushrajRathod/pTimeout

License