( f: (...a: A) => B )
| 1001 | * @since 2.0.0 |
| 1002 | */ |
| 1003 | export const liftThrowable = <A extends ReadonlyArray<unknown>, B>( |
| 1004 | f: (...a: A) => B |
| 1005 | ): (...a: A) => Option<B> => |
| 1006 | (...a) => { |
| 1007 | try { |
| 1008 | return some(f(...a)) |
| 1009 | } catch { |
| 1010 | return none() |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | /** |
| 1015 | * Extracts the value from a `Some`, or throws a custom error for `None`. |