diff options
author | Francesco Agosti <francesco.agosti93@gmail.com> | 2019-01-11 01:33:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-11 01:33:22 +0800 |
commit | bf332d578c5d229b3a8d39bf5935233ecf9526c8 (patch) | |
tree | 81a511b3e23b30445a2326940a494cc911716835 /packages/utils | |
parent | 6c22594882c94146519ec6e3b24d558127bd092c (diff) | |
parent | b639843115547fc3d259fcfb98599a16187b3d07 (diff) | |
download | dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.gz dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.bz2 dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.lz dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.xz dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.tar.zst dexon-sol-tools-bf332d578c5d229b3a8d39bf5935233ecf9526c8.zip |
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)
Diffstat (limited to 'packages/utils')
-rw-r--r-- | packages/utils/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/utils/src/promisify.ts | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index fb85c4174..d84e32dd2 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "3.0.0", + "changes": [ + { + "note": "Make `promisify` resolve when the callback error is undefined.", + "pr": 1501 + } + ] + }, + { "version": "2.1.1", "changes": [ { diff --git a/packages/utils/src/promisify.ts b/packages/utils/src/promisify.ts index 29d626b61..e82251a0f 100644 --- a/packages/utils/src/promisify.ts +++ b/packages/utils/src/promisify.ts @@ -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]); }); |