File: index.js

package info (click to toggle)
node-p-finally 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 100 kB
  • sloc: makefile: 2; sh: 2
file content (15 lines) | stat: -rw-r--r-- 302 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'use strict';
module.exports = (promise, onFinally) => {
	onFinally = onFinally || (() => {});

	return promise.then(
		val => new Promise(resolve => {
			resolve(onFinally());
		}).then(() => val),
		err => new Promise(resolve => {
			resolve(onFinally());
		}).then(() => {
			throw err;
		})
	);
};