has-resolved

1.1.0 • Public • Published

has-resolved

Checks if a Promise is resolved or rejected asynchronously

npm version Build Status

How to use

Resolution and rejection checks are asynchronous. You can use ES6 async/await to simplify coding.

Check for resolution

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

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 us.

Want to make it better? File us an issue.

Don't like something you see? Submit a pull request.

Package Sidebar

Install

npm i has-resolved

Weekly Downloads

94

Version

1.1.0

License

MIT

Unpacked Size

8.7 kB

Total Files

7

Last publish

Collaborators

  • compulim