Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
949 bytes
|
Line | |
---|
1 | # p-finally [![Build Status](https://travis-ci.org/sindresorhus/p-finally.svg?branch=master)](https://travis-ci.org/sindresorhus/p-finally)
|
---|
2 |
|
---|
3 | > [`Promise#finally()`](https://github.com/tc39/proposal-promise-finally) [ponyfill](https://ponyfill.com) - Invoked when the promise is settled regardless of outcome
|
---|
4 |
|
---|
5 | Useful for cleanup.
|
---|
6 |
|
---|
7 |
|
---|
8 | ## Install
|
---|
9 |
|
---|
10 | ```
|
---|
11 | $ npm install --save p-finally
|
---|
12 | ```
|
---|
13 |
|
---|
14 |
|
---|
15 | ## Usage
|
---|
16 |
|
---|
17 | ```js
|
---|
18 | const pFinally = require('p-finally');
|
---|
19 |
|
---|
20 | const dir = createTempDir();
|
---|
21 |
|
---|
22 | pFinally(write(dir), () => cleanup(dir));
|
---|
23 | ```
|
---|
24 |
|
---|
25 |
|
---|
26 | ## API
|
---|
27 |
|
---|
28 | ### pFinally(promise, [onFinally])
|
---|
29 |
|
---|
30 | Returns a `Promise`.
|
---|
31 |
|
---|
32 | #### onFinally
|
---|
33 |
|
---|
34 | Type: `Function`
|
---|
35 |
|
---|
36 | Note: Throwing or returning a rejected promise will reject `promise` with the rejection reason.
|
---|
37 |
|
---|
38 |
|
---|
39 | ## Related
|
---|
40 |
|
---|
41 | - [p-try](https://github.com/sindresorhus/p-try) - `Promise#try()` ponyfill - Starts a promise chain
|
---|
42 | - [More…](https://github.com/sindresorhus/promise-fun)
|
---|
43 |
|
---|
44 |
|
---|
45 | ## License
|
---|
46 |
|
---|
47 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.