Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
index.js | D | 12-May-2024 | 302 | 16 | 14 | |
license | D | 12-May-2024 | 1.1 KiB | 22 | 17 | |
package.json | D | 12-May-2024 | 1.6 KiB | 75 | 74 | |
readme.md | D | 12-May-2024 | 949 | 48 | 24 |
readme.md
1# p-finally [](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 5Useful for cleanup. 6 7 8## Install 9 10``` 11$ npm install --save p-finally 12``` 13 14 15## Usage 16 17```js 18const pFinally = require('p-finally'); 19 20const dir = createTempDir(); 21 22pFinally(write(dir), () => cleanup(dir)); 23``` 24 25 26## API 27 28### pFinally(promise, [onFinally]) 29 30Returns a `Promise`. 31 32#### onFinally 33 34Type: `Function` 35 36Note: 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 47MIT © [Sindre Sorhus](https://sindresorhus.com) 48