Merge pull request #1501 from 0xProject/fix/utils/promisify-not-accounting-for-undefined-error

[utils] account for undefined errors in promisify, not only null (and fix instant in Opera)
This commit is contained in:
Francesco Agosti
2019-01-10 09:33:22 -08:00
committed by GitHub
2 changed files with 10 additions and 1 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "3.0.0",
"changes": [
{
"note": "Make `promisify` resolve when the callback error is undefined.",
"pr": 1501
}
]
},
{
"version": "2.1.1",
"changes": [

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]);
});