p-finally
`Promise#finally()` ponyfill - Invoked when the promise is settled regardless of outcome
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install p-finally 
SYNC missed versions from official npm registry.

p-finally Build Status

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

Useful for cleanup.

Install

$ npm install p-finally

Usage

const pFinally = require('p-finally');

const directory = createTempDirectory();

(async () => {
	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 - Promise.try() ponyfill - Starts a promise chain
  • More…

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Current Tags

  • 2.0.1                                ...           latest (a year ago)

3 Versions

  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 7,139
This Week 7,139
This Month 422,189
Last Day 14,746
Last Week 252,564
Last Month 1,046,487
Dependencies (0)
None
Dev Dependencies (2)
Dependents (85)

Copyright 2014 - 2017 © taobao.org |