You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
302 B

4 years ago
  1. 'use strict';
  2. module.exports = (promise, onFinally) => {
  3. onFinally = onFinally || (() => {});
  4. return promise.then(
  5. val => new Promise(resolve => {
  6. resolve(onFinally());
  7. }).then(() => val),
  8. err => new Promise(resolve => {
  9. resolve(onFinally());
  10. }).then(() => {
  11. throw err;
  12. })
  13. );
  14. };