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

Function firstSomeOf

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

Source from the content-addressed store, hash-verified

753 * @since 2.0.0
754 */
755export 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`.

Callers

nothing calls this directly

Calls 2

isSomeFunction · 0.85
noneFunction · 0.70

Tested by

no test coverage detected