Fix async callbacks

This commit is contained in:
Leonid Logvinov
2017-11-20 16:39:34 -06:00
parent 3bc3666215
commit 3e0371685f
3 changed files with 14 additions and 15 deletions

View File

@@ -1,10 +1,10 @@
import { DoneCallback } from '../../src/types';
export const reportCallbackErrors = (done: DoneCallback) => {
return (f: (...args: any[]) => void) => {
const wrapped = (...args: any[]) => {
return (fAsync: (...args: any[]) => void|Promise<void>) => {
const wrapped = async (...args: any[]) => {
try {
f(...args);
await fAsync(...args);
} catch (err) {
done(err);
}