MCPcopy Index your code
hub / github.com/Effect-TS/effect / gen

Function gen

packages/effect/src/Option.ts:2141–2155  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

2139 * @since 2.0.0
2140 */
2141export const gen: Gen.Gen<OptionTypeLambda, Gen.Adapter<OptionTypeLambda>> = (...args) => {
2142 const f = args.length === 1 ? args[0] : args[1].bind(args[0])
2143 const iterator = f(adapter)
2144 let state: IteratorResult<any> = iterator.next()
2145 while (!state.done) {
2146 const current = Gen.isGenKind(state.value)
2147 ? state.value.value
2148 : Gen.yieldWrapGet(state.value)
2149 if (isNone(current)) {
2150 return current
2151 }
2152 state = iterator.next(current.value as never)
2153 }
2154 return some(state.value)
2155}
2156
2157/**
2158 * Merges two optional values, applying a function if both exist.

Callers

nothing calls this directly

Calls 4

fFunction · 0.70
someFunction · 0.70
nextMethod · 0.65
isNoneFunction · 0.50

Tested by

no test coverage detected