source:
node_modules/es-toolkit/dist/compat/function/attempt.mjs
| Last change on this file was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 179 bytes | |
| Line | |
|---|---|
| 1 | function attempt(func, ...args) { |
| 2 | try { |
| 3 | return func(...args); |
| 4 | } |
| 5 | catch (e) { |
| 6 | return e instanceof Error ? e : new Error(e); |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | export { attempt }; |
Note:
See TracBrowser
for help on using the repository browser.
