Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.14 KB

README.md

File metadata and controls

34 lines (26 loc) · 1.14 KB

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
    }
}