# promise.prototype.finally

> ES Proposal spec-compliant shim for Promise.prototype.finally

Latest version **3.1.8** (published 2024-02-05) · MIT license · 0 weekly downloads

> **Native alternative:** Promise.prototype.finally — Use native JavaScript (Node 10.0.0+) (https://developer.mozilla.orgGlobal_Objects/Promise/finally)

## Install

```sh
npm install promise.prototype.finally
pnpm add promise.prototype.finally
yarn add promise.prototype.finally
bun add promise.prototype.finally
```

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.1.8 |
| Published | 2024-02-05 |
| First published | 2014-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/promise.prototype.finally) |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 5 |
| Unpacked size | 30.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 140 |
| Author | Jordan Harband |
| Maintainers | ljharb, mattandrews |
| Keywords | Promise, promises, finally, promise.prototype.finally, ES7, ES8, ES2017, shim, polyfill, es-shim API |

## Links

- npm: https://www.npmjs.com/package/promise.prototype.finally
- Repository: https://github.com/es-shims/Promise.prototype.finally
- Homepage: https://github.com/es-shims/Promise.prototype.finally#readme
- Issues: https://github.com/es-shims/Promise.prototype.finally/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/promise.prototype.finally

## Dependencies (5)

- [call-bind](https://npm.io/package/call-bind.md) ^1.0.5
- [es-errors](https://npm.io/package/es-errors.md) ^1.0.0
- [es-abstract](https://npm.io/package/es-abstract.md) ^1.22.3
- [define-properties](https://npm.io/package/define-properties.md) ^1.2.1
- [set-function-name](https://npm.io/package/set-function-name.md) ^2.0.1

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.1.8 (latest) — 2024-02-05
- 3.1.7 — 2023-09-13
- 3.1.5 — 2023-08-30
- 3.1.4 — 2022-11-07
- 3.1.3 — 2021-10-04
- 3.1.2 — 2019-12-11
- 3.1.1 — 2019-08-25
- 3.1.0 — 2017-10-27
- 3.0.1 — 2017-09-09
- 3.0.0 — 2017-07-25
- 2.0.1 — 2016-09-27
- 2.0.0 — 2016-08-21
- 1.0.1 — 2015-02-09
- 1.0.0 — 2014-10-11

## README

# promise.prototype.finally <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

ES Proposal spec-compliant shim for Promise.prototype.finally. Invoke its "shim" method to shim `Promise.prototype.finally` if it is unavailable or noncompliant. **Note**: a global `Promise` must already exist: the [es6-shim](https://github.com/es-shims/es6-shim) is recommended.

This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment that has `Promise` available globally, and complies with the [proposed spec](https://github.com/tc39/proposal-promise-finally).

Most common usage:
```js
var assert = require('assert');
var promiseFinally = require('promise.prototype.finally');

var resolved = Promise.resolve(42);
var rejected = Promise.reject(-1);

promiseFinally(resolved, function () {
	assert.equal(arguments.length, 0);

	return Promise.resolve(true);
}).then(function (x) {
	assert.equal(x, 42);
});

promiseFinally(rejected, function () {
	assert.equal(arguments.length, 0);
}).catch(function (e) {
	assert.equal(e, -1);
});

promiseFinally(rejected, function () {
	assert.equal(arguments.length, 0);

	throw false;
}).catch(function (e) {
	assert.equal(e, false);
});

promiseFinally.shim(); // will be a no-op if not needed

resolved.finally(function () {
	assert.equal(arguments.length, 0);

	return Promise.resolve(true);
}).then(function (x) {
	assert.equal(x, 42);
});

rejected.finally(function () {
	assert.equal(arguments.length, 0);
}).catch(function (e) {
	assert.equal(e, -1);
});

rejected.finally(function () {
	assert.equal(arguments.length, 0);

	throw false;
}).catch(function (e) {
	assert.equal(e, false);
});
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

## Thanks
Huge thanks go out to [@matthew-andrews](https://github.com/matthew-andrews), who provided the npm package name for v2 of this module. v1 is both in [the original repo][v1-repo-url] and preserved in [a branch][v1-branch-url]

[package-url]: https://npmjs.com/package/promise.prototype.finally
[npm-version-svg]: http://versionbadg.es/es-shims/Promise.prototype.finally.svg
[deps-svg]: https://david-dm.org/es-shims/Promise.prototype.finally.svg
[deps-url]: https://david-dm.org/es-shims/Promise.prototype.finally
[dev-deps-svg]: https://david-dm.org/es-shims/Promise.prototype.finally/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/Promise.prototype.finally#info=devDependencies
[testling-svg]: https://ci.testling.com/es-shims/Promise.prototype.finally.png
[testling-url]: https://ci.testling.com/es-shims/Promise.prototype.finally
[npm-badge-png]: https://nodei.co/npm/promise.prototype.finally.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/promise.prototype.finally.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/promise.prototype.finally.svg
[downloads-url]: http://npm-stat.com/charts.html?package=promise.prototype.finally
[v1-repo-url]: https://github.com/matthew-andrews/Promise.prototype.finally
[v1-branch-url]: https://github.com/es-shims/Promise.prototype.finally/tree/v1
[codecov-image]: https://codecov.io/gh/es-shims/Promise.prototype.finally/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/Promise.prototype.finally/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Promise.prototype.finally
[actions-url]: https://github.com/es-shims/Promise.prototype.finally/actions

---
_Source: https://npm.io/package/promise.prototype.finally · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
