# p-finally

> `Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome

Latest version **3.0.0** (published 2021-04-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install p-finally
pnpm add p-finally
yarn add p-finally
bun add p-finally
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-04-09 |
| First published | 2016-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | promise, finally, handler, function, async, await, promises, settled, ponyfill, polyfill, shim, bluebird |

## Links

- npm: https://www.npmjs.com/package/p-finally
- Repository: https://github.com/sindresorhus/p-finally
- Homepage: https://github.com/sindresorhus/p-finally#readme
- Issues: https://github.com/sindresorhus/p-finally/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/p-finally

## 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.0.0 (latest) — 2021-04-09
- 2.0.1 — 2019-06-19
- 2.0.0 — 2019-05-28
- 1.0.0 — 2016-10-21

## README

# p-finally

> [`Promise#finally()`](https://github.com/tc39/proposal-promise-finally) [ponyfill](https://ponyfill.com) - Invoked when the promise is settled regardless of outcome

Useful for cleanup.

## Install

```
$ npm install p-finally
```

## Usage

```js
import pFinally from 'p-finally';

const directory = createTempDirectory();

await pFinally(write(directory), () => {
	cleanup(directory);
});
```

## API

### pFinally(promise, onFinally?)

Returns a `Promise`.

#### onFinally

Type: `Function`

Note: Throwing or returning a rejected promise will reject `promise` with the rejection reason.

## Related

- [p-try](https://github.com/sindresorhus/p-try) - `Promise.try()` ponyfill - Starts a promise chain
- [More…](https://github.com/sindresorhus/promise-fun)

---

<div align="center">
	<b>
		<a href="https://tidelift.com/subscription/pkg/npm-p-finally?utm_source=npm-p-finally&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
	</b>
	<br>
	<sub>
		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
	</sub>
</div>

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