UNPKG

p-finally

Version:

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

16 lines (14 loc) 218 B
export default async function pFinally( promise, onFinally = (() => {}) ) { let value; try { value = await promise; } catch (error) { await onFinally(); throw error; } await onFinally(); return value; }