diff options
Diffstat (limited to 'extension/lib')
-rw-r--r-- | extension/lib/util.js | 4 | ||||
-rw-r--r-- | extension/lib/util.ts | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/extension/lib/util.js b/extension/lib/util.js index 801d7d189..71bfce4d3 100644 --- a/extension/lib/util.js +++ b/extension/lib/util.js @@ -28,3 +28,7 @@ function format(s, ...args) { s = s.replace(/{([0-9]+)}/g, r); return s; } +function promiseFinally(p, fn) { + return p.then((x) => { fn(); return x; }) + .catch((e) => { fn(); throw e; }); +} diff --git a/extension/lib/util.ts b/extension/lib/util.ts index 106e22970..b30d60432 100644 --- a/extension/lib/util.ts +++ b/extension/lib/util.ts @@ -32,3 +32,8 @@ function format(s: string, ...args: any[]) { return s; } + +function promiseFinally<T>(p: Promise<T>, fn): Promise<T> { + return p.then((x) => { fn(); return x; }) + .catch((e) => {fn(); throw e;}); +}
\ No newline at end of file |