1.0.2 • Published 8 years ago

once-done v1.0.2

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

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
});
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago