bluefeather
Advanced tools
Comparing version
@@ -8,13 +8,11 @@ "use strict"; | ||
const suppress = async (ErrorConstructor, promise) => { | ||
try { | ||
return await promise; | ||
} catch (error) { | ||
const suppress = (ErrorConstructor, promise) => { | ||
return promise.catch(error => { | ||
if (error instanceof ErrorConstructor) { | ||
// eslint-disable-next-line consistent-return | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} else { | ||
throw error; | ||
} | ||
throw error; | ||
} | ||
}); | ||
}; | ||
@@ -21,0 +19,0 @@ |
@@ -64,3 +64,3 @@ { | ||
}, | ||
"version": "2.3.0" | ||
"version": "2.3.1" | ||
} |
// @flow | ||
type SuppressType = <T: *>( | ||
type SuppressType = <T: Promise<*>>( | ||
ErrorConstructor: Class<Error>, | ||
promise: Promise<T> | ||
promise: T | ||
) => Promise<T | void>; | ||
const suppress: SuppressType = async (ErrorConstructor, promise) => { | ||
try { | ||
return await promise; | ||
} catch (error) { | ||
if (error instanceof ErrorConstructor) { | ||
// eslint-disable-next-line consistent-return | ||
return; | ||
} | ||
throw error; | ||
} | ||
const suppress: SuppressType = (ErrorConstructor, promise) => { | ||
return promise | ||
.catch((error) => { | ||
if (error instanceof ErrorConstructor) { | ||
// eslint-disable-next-line no-useless-return | ||
return; | ||
} else { | ||
throw error; | ||
} | ||
}); | ||
}; | ||
export default suppress; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
18435
0.17%196
-0.51%