# once-done

> Call a callback when a Promise is settled.

Latest version **1.0.2** (published 2016-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install once-done
pnpm add once-done
yarn add once-done
bun add once-done
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-01-21 |
| First published | 2016-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Andrey Belym |
| Maintainers | belym.a.2105 |
| Keywords | promise |

## Links

- npm: https://www.npmjs.com/package/once-done
- Repository: https://github.com/AndreyBelym/once-done
- Homepage: https://github.com/AndreyBelym/once-done#readme
- Issues: https://github.com/AndreyBelym/once-done/issues
- npm.io page: https://npm.io/package/once-done

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@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

## Recent versions

- 1.0.2 (latest) — 2016-01-21
- 1.0.1 — 2016-01-21
- 1.0.0 — 2016-01-21

## README

# once-done
[![Build Status](https://travis-ci.org/AndreyBelym/once-done.svg?branch=master)](https://travis-ci.org/AndreyBelym/once-done)

*Call a function when a Promise is settled.*

Implementation of [Promise.prototype.finally](https://gist.github.com/rbuckton/66918c8491aa335b003c) as non-method function.

Written in ES6, transpiled by [Babel](http://babeljs.io/).

## 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
});
```

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