Socket
Socket
Sign inDemoInstall

promise.prototype.finally

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    promise.prototype.finally

A polyfill for Promise.prototype.finally for ES6 compliant promises


Version published
Maintainers
1
Install size
5.17 kB
Created

Package description

What is promise.prototype.finally?

The promise.prototype.finally package provides a polyfill for the `finally` method on the Promise prototype. This method allows for a callback to be executed when the promise is settled, regardless of its outcome (fulfilled or rejected). It is useful for running cleanup code or finalizing operations without caring about the promise's resolution.

What are promise.prototype.finally's main functionalities?

Adding finally support to Promises

This feature allows for the addition of the `finally` method to the Promise prototype, enabling cleanup or final operations to be run regardless of whether the promise was fulfilled or rejected.

require('promise.prototype.finally').shim();

new Promise((resolve, reject) => {
  // Asynchronous operation
}).finally(() => {
  // Cleanup or final code to run regardless of promise outcome
});

Other packages similar to promise.prototype.finally

Readme

Source

Promise.prototype.finally Codeship Status for matthew-andrews/Promise.prototype.finally

A polyfill for Promise.prototype.finally. See docs on what finally is on your favourite pre-ES6 promise library.

Warning: This micro-library doesn't force you to use any particular Promise implementation by using whatever Promise has been defined as globally. This is so that you may use any ES6 standard Promise compliant library - or, of course, native ES6 Promises.

If you're running the code on a browser or node version that doesn't include native promises you will need to include a polyfill. The following polyfills are tested as part of this module's test suite:-

Installation

npm install promise.prototype.finally --save

Examples

require('es6-promise').polyfill();
require('promise.prototype.finally');

Promise.resolve(6)
	.finally(function() {
		console.log('this will always be called');
	});

Promise.reject(6)
	.finally(function() {
		console.log('this will always be called');
	});

Credits and collaboration

The lead developer of Promise.prototype.finally is Matt Andrews at FT with unwitting help and support from Stefan Penner. All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.

FAQs

Last updated on 11 Oct 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc