mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 05:47:10 -04:00
refactor(base64): mutualized base64 functions into global utilities
This commit is contained in:
parent
ca7cb44389
commit
447bdf2148
8 changed files with 138 additions and 12 deletions
9
src/utils/defaults.ts
Normal file
9
src/utils/defaults.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export { withDefaultOnError };
|
||||
|
||||
function withDefaultOnError<A, B>(cb: () => A, defaultValue: B): A | B {
|
||||
try {
|
||||
return cb();
|
||||
} catch (_) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue