promise-status-async
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.10 • Public • Published

    promise-status-async

    Promise status management tool

    promise status logo

    Install

    npm install promise-status-async

    API

    Follow promise-status-async API for more details.

    Usage example

    import {
        PromiseStatuses,
        PROMISE_RESOLVED,
        promiseStatus,
        promiseState,
        isPromiseResolved,
        isPromiseNotRejected
    } from 'promise-status-async';
    
    const pendingPromise = new Promise(() => {});
    const resolvedPromise = Promise.resolve('some value');
    const rejectedPromise = Promise.reject('some reason');
    
    (async function usageExample () {
        console.log(await promiseStatus(pendingPromise));
        // pending
    
        console.log(await promiseStatus(rejectedPromise) === PromiseStatuses.PROMISE_REJECTED);
        // true
    
        console.log(await promiseStatus(resolvedPromise) === PROMISE_RESOLVED);
        // true
    
        console.log(await promiseState(resolvedPromise));
        // {status: "resolved", value: "some value"}
    
        console.log(await isPromiseResolved(pendingPromise));
        // false
    
        console.log(await isPromiseNotRejected(resolvedPromise));
        // true
    })();

    Install

    npm i promise-status-async

    DownloadsWeekly Downloads

    924

    Version

    1.2.10

    License

    MIT

    Unpacked Size

    25.1 kB

    Total Files

    19

    Last publish

    Collaborators

    • kudla