( f: (...a: A) => B )
| 137 | * @since 4.0.0 |
| 138 | */ |
| 139 | export const liftThrowable = <A extends ReadonlyArray<unknown>, B>( |
| 140 | f: (...a: A) => B |
| 141 | ): (...a: A) => B | undefined => |
| 142 | (...a) => { |
| 143 | try { |
| 144 | return f(...a) |
| 145 | } catch { |
| 146 | return undefined |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Creates a `Reducer` for `UndefinedOr<A>` that prioritizes the first non-`undefined` |