( collection: C )
| 753 | * @since 2.0.0 |
| 754 | */ |
| 755 | export const firstSomeOf = <T, C extends Iterable<Option<T>> = Iterable<Option<T>>>( |
| 756 | collection: C |
| 757 | ): [C] extends [Iterable<Option<infer A>>] ? Option<A> : never => { |
| 758 | let out: Option<unknown> = none() |
| 759 | for (out of collection) { |
| 760 | if (isSome(out)) { |
| 761 | return out as any |
| 762 | } |
| 763 | } |
| 764 | return out as any |
| 765 | } |
| 766 | |
| 767 | /** |
| 768 | * Converts a nullable value (`null` or `undefined`) into an `Option`. |