line_push/node_modules/p-finally/index.js
2022-07-17 13:16:16 +08:00

18 lines
222 B
JavaScript

'use strict';
module.exports = async (
promise,
onFinally = (() => {})
) => {
let value;
try {
value = await promise;
} catch (error) {
await onFinally();
throw error;
}
await onFinally();
return value;
};