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

Function gen

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

Source from the content-addressed store, hash-verified

2349 * @since 2.0.0
2350 */
2351export const gen: Gen.Gen<OptionTypeLambda> = (...args) => {
2352 const f = args.length === 1 ? args[0] : args[1].bind(args[0])
2353 const iterator = f()
2354 let state: IteratorResult<any> = iterator.next()
2355 while (!state.done) {
2356 const current = state.value
2357 if (isNone(current)) {
2358 return current
2359 }
2360 state = iterator.next(current.value as never)
2361 }
2362 return some(state.value)
2363}
2364
2365/**
2366 * Creates a `Reducer` for `Option<A>` that prioritizes the first non-`None`

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected