once-done

1.0.2 • Public • Published

once-done

Build Status

Call a function when a Promise is settled.

Implementation of Promise.prototype.finally as non-method function.

Written in ES6, transpiled by Babel.

Install

npm install once-done

Usage

Use it like try..finally for promises:

var onceDone = require('once-done');

var file = getFile();

var someResultPromise = handleFileAsync(); //someStatsPromise may be rejected

onceDone(someResultPromise, function () {
    file.close(); //Close the file in any situation
    return file.deleteAsync(); //You may return Promise, and it will be resolved!
})
.then(function (result) {
    //Handle the result
})
.catch(function (reason) {
    //Check a reason of rejection
});

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i once-done

    Weekly Downloads

    14

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • belym.a.2105