Skip to content

Commit c0d2400

Browse files
committed
feat(shared): add ignoreError()
1 parent 57ddbf7 commit c0d2400

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/lib/src/error.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function ignoreError<T>(fn: () => T): T | undefined {
2+
try {
3+
return fn();
4+
} catch {
5+
// do nothing
6+
}
7+
}

packages/lib/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { shuffle } from './shuffle.js';
2+
export { ignoreError } from './error.js';
23
export { zenkakuAlphanumericalsToHankaku } from './zenkaku.js';

0 commit comments

Comments
 (0)