0.1.0 • Published 6 years ago
promise-stateful v0.1.0
promise-stateful
Native Promise wrapper with state getters
(isPending, isFulfilled, isRejected).
Installation
npm install promise-statefulUsage
import PromiseStateful from 'promise-stateful';Constructor
Create a new promise the same way as you would with the Promise constructor:
let p = new PromiseStateful((res, rej) => {
// ...
});
p.isPending; // true
p.isFulfilled; // false
p.isRejected; // falseAlso works with Promise static methods:
let p = PromiseStateful.resolve('foo');
p.isPending; // false
p.isFulfilled; // truePromiseStateful.from
Create a PromiseStateful from an existing Promise with
PromiseStateful.from:
let nativePromise = Promise.resolve(123);
nativePromise.isFulfilled; // undefined
let p = PromiseStateful.from(nativePromise);
p.isFulfilled; // trueLicense
This software is released under the terms of the MIT license. See LICENSE.
0.1.0
6 years ago