promto
promto
Wrappes A Promise In Timeout.
yarn add promto
Table Of Contents
- Table Of Contents
- API
async promto(promise: Promise, timeout: number, description: string?): Promise
- Copyright
API
The package is available by importing its default function:
async promto(
promise: Promise,
timeout: number,
description: string?,
): Promise
Creates a new promise which will be rejected upon timeout (after N milliseconds). It will be resolved with the promise value or rejected with the promise error when not timed out.
/** * @param * @param */const makePromise = async { await { } if result instanceof Error throw result return result} async { // ok const res = await console // rejected timeout try await catch err console // rejected timeout with description try await catch err console // rejected promise try await catch err console }
hello
Promise has timed out after 100ms
Example has timed out after 100ms
Error in promise
Copyright
© Art Deco 2019 | Tech Nation Visa Sucks |
---|