https://github.com/c-geek/querablep
Know the state of your promise: rejected, resolved, fulfilled.
https://github.com/c-geek/querablep
Last synced: 4 months ago
JSON representation
Know the state of your promise: rejected, resolved, fulfilled.
- Host: GitHub
- URL: https://github.com/c-geek/querablep
- Owner: c-geek
- License: agpl-3.0
- Created: 2017-01-18T12:32:50.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-18T12:37:11.000Z (almost 9 years ago)
- Last Synced: 2025-06-01T12:03:07.460Z (5 months ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
querablep
=========
Allows you to ask your promise few questions:
* is it done? (finished, whatever is the result)
* is it resolved? (success)
* is it rejected? (failure)
Usage
-----
.. code:: javascript
const querablep = require('querablep')
// Business code
const peoplePromise = querablep(getPeopleInDatabasePromise());
peoplePromise.isFulfilled(); // false
peoplePromise.isRejected(); // false
peoplePromise.isResoleved(); // false
peoplePromise
.catch((e) => {
peoplePromise.isFulfilled(); // true
peoplePromise.isRejected(); // true
peoplePromise.isResoleved(); // false
})
.then((people) => {
peoplePromise.isFulfilled(); // true
peoplePromise.isRejected(); // false
peoplePromise.isResoleved(); // true
});
Credits
-------
This code is a copy/paste from this answer `on Stackoverflow by chuckj`_. But now under AGPL.
.. _`on Stackoverflow by chuckj`: http://stackoverflow.com/a/21489870/1137410