( f: (...a: A) => B )
| 810 | * @since 2.0.0 |
| 811 | */ |
| 812 | export const liftThrowable = <A extends ReadonlyArray<unknown>, B>( |
| 813 | f: (...a: A) => B |
| 814 | ): (...a: A) => Option<B> => |
| 815 | (...a) => { |
| 816 | try { |
| 817 | return some(f(...a)) |
| 818 | } catch { |
| 819 | return none() |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | /** |
| 824 | * Extracts the value of an `Option` or throws an error if the `Option` is |