fix: account for undefined errors in promisify, not only null

This commit is contained in:
fragosti
2019-01-09 18:26:18 -08:00
parent 87c287a5e2
commit 7a114a6ef1

View File

@@ -10,7 +10,7 @@ export function promisify<T>(originalFn: (...args: any[]) => void, thisArg?: any
const promisifiedFunction = async (...callArgs: any[]): Promise<T> => {
return new Promise<T>((resolve, reject) => {
const callback = (err: Error | null, data?: T) => {
_.isNull(err) ? resolve(data) : reject(err);
_.isNull(err) || _.isUndefined(err) ? resolve(data) : reject(err);
};
originalFn.apply(thisArg, [...callArgs, callback]);
});