Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/promise timeout #21

Merged
merged 3 commits into from
Jul 1, 2019
Merged

Feature/promise timeout #21

merged 3 commits into from
Jul 1, 2019

Conversation

jsconan
Copy link
Contributor

@jsconan jsconan commented Jun 26, 2019

Add a helper that watches a promise and reject it if its duration exceeds the given amount of milliseconds.

promiseTimeout(promise, {timeout: 1000})
    .then(() => {
        // ...
    })
    .catch(err => {
        if (err && err.timeout) {
            // ...
        } else {
            // ...
        }
    });

Unit test:

npm run prepare
npm run test promiseTimeout

Copy link
Contributor

@krampstudio krampstudio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

@krampstudio krampstudio merged commit 9ea71f0 into develop Jul 1, 2019
@krampstudio krampstudio deleted the feature/promise-timeout branch July 1, 2019 07:28
@jsconan jsconan mentioned this pull request Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants