MCPcopy Create free account
hub / github.com/Effect-TS/effect / firstSomeOf

Function firstSomeOf

packages/effect/src/Option.ts:731–741  ·  view source on GitHub ↗
(
  collection: C
)

Source from the content-addressed store, hash-verified

729 * @since 2.0.0
730 */
731export 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`.

Callers

nothing calls this directly

Calls 2

isSomeFunction · 0.85
noneFunction · 0.70

Tested by

no test coverage detected