Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/compulim/has-resolved
Checks if a Promise is resolved or rejected asynchronously
https://github.com/compulim/has-resolved
asynchronous promise rejection resolution
Last synced: about 2 months ago
JSON representation
Checks if a Promise is resolved or rejected asynchronously
- Host: GitHub
- URL: https://github.com/compulim/has-resolved
- Owner: compulim
- License: mit
- Created: 2018-03-27T00:52:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:32:51.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T01:37:33.635Z (about 2 months ago)
- Topics: asynchronous, promise, rejection, resolution
- Language: JavaScript
- Homepage:
- Size: 1.06 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# has-resolved
Checks if a Promise is resolved or rejected asynchronously
[![npm version](https://badge.fury.io/js/has-resolved.svg)](https://badge.fury.io/js/has-resolved) [![Build Status](https://travis-ci.org/compulim/has-resolved.svg?branch=master)](https://travis-ci.org/compulim/has-resolved)
# How to use
Resolution and rejection checks are asynchronous. You can use ES6 `async`/`await` to simplify coding.
## Check for resolution
```js
import hasResolved from 'has-resolved';const promise = Promise.resolve();
const resolved = await hasResolved(promise);expect(resolved).toBeTruthy();
```> Please note that `hasResolved` is an asynchronous function and need to be `await`-ed.
## Check for rejection
```js
import { hasRejected } from 'has-resolved';const promise = Promise.reject();
const rejected = await hasRejected(promise);expect(rejected).toBeTruthy();
```> `hasRejected` is not a default export, thus, the bracelets is needed for named import.
# Contributions
Like us? [Star](https://github.com/compulim/has-resolved/stargazers) us.
Want to make it better? [File](https://github.com/compulim/has-resolved/issues) us an issue.
Don't like something you see? [Submit](https://github.com/compulim/has-resolved/pulls) a pull request.