refactor(base64): mutualized base64 functions into global utilities

This commit is contained in:
Corentin Thomasset 2022-08-04 12:09:32 +02:00
parent ca7cb44389
commit 447bdf2148
No known key found for this signature in database
GPG key ID: 3103EB5E79496F9C
8 changed files with 138 additions and 12 deletions

9
src/utils/defaults.ts Normal file
View file

@ -0,0 +1,9 @@
export { withDefaultOnError };
function withDefaultOnError<A, B>(cb: () => A, defaultValue: B): A | B {
try {
return cb();
} catch (_) {
return defaultValue;
}
}