Nancy's Preferred Machete
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    do-thenpublic

    DO-THEN

    Realise sync or async tasks as promises, resolve to do the next step or reject and catch an error.

    INSTALL

    npm i do-then

    USE / EXAMPLE

    new Do(function( resolve, reject ){
     
        resolve("nope");
     
    })
    .then(function( resolve, reject, promise ){
     
        if( promise == "foo" ){
     
            resolve("bar");
     
        }
        else {
     
            reject("promise is not equal to 'foo' but '" + promise + "'");
     
        };
     
    })
    .then(function( resolve, reject, promise ){
     
        if( promise == "bar" ){
     
            console.info("Promise is correct");
     
        }
        else {
     
            reject("Promise is not correct");
     
        };
     
     
    })
    .catch(function( retry, promise ){
     
        console.error("catch error: ", promise);
     
        retry(false, function( resolve, reject ){
     
            console.log("restart")
     
            resolve("foo");
     
        }, function( retry, promise ){
     
            console.error("Cant do nothing at all...");
     
        });
     
    });

    install

    npm i do-then

    Downloadsweekly downloads

    2

    version

    1.0.1

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar