promise-until-tired
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Promise until tired

semantic-release JavaScript Style Guide ts code style: prettier License: MIT

Too long unresolved promise is tired and I gonna give up.

This is the promise with timeout.

Installation

yarn add promise-until-tired

Usage

import newPromiseUntilTired, { TiredFromWaitingPromiseResolveTooLongError } from 'promise-until-tired'

try {
    const value = await newPromiseUntilTired((resolve, reject) => {
        // logic
    }, timeout)
} catch (error) {
    if (error instanceof TiredFromWaitingPromiseResolveTooLongError) {
        // handle timeout logic
    } else {
        // handle other reject logic
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i promise-until-tired

Weekly Downloads

11

Version

1.0.1

License

MIT

Unpacked Size

127 kB

Total Files

27

Last publish

Collaborators

  • reiiyuki