( collection: C )
| 729 | * @since 2.0.0 |
| 730 | */ |
| 731 | export const firstSomeOf = <T, C extends Iterable<Option<T>> = Iterable<Option<T>>>( |
| 732 | collection: C |
| 733 | ): [C] extends [Iterable<Option<infer A>>] ? Option<A> : never => { |
| 734 | let out: Option<unknown> = none() |
| 735 | for (out of collection) { |
| 736 | if (isSome(out)) { |
| 737 | return out as any |
| 738 | } |
| 739 | } |
| 740 | return out as any |
| 741 | } |
| 742 | |
| 743 | /** |
| 744 | * Converts a nullable value (`null` or `undefined`) into an `Option`. |