Skip to content

Instantly share code, notes, and snippets.

@ramingar
Created January 18, 2019 09:17
Show Gist options
  • Save ramingar/cd4717b20baa23d547b6782706b1c961 to your computer and use it in GitHub Desktop.
Save ramingar/cd4717b20baa23d547b6782706b1c961 to your computer and use it in GitHub Desktop.
Finally polyfill para versiones de node antiguas #node #finally #polyfill
Promise.prototype.finally = function (cb) {
    const res = () => this;
    return this.then(value =>
            Promise.resolve(cb({state: "fulfilled", value})).then(res)
        , reason =>
            Promise.resolve(cb({state: "rejected", reason})).then(res)
    );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment