/** * Creates a stream from an effect producing a value of type `A`, which is * repeated using the specified schedule. * * @tsplus static effect/core/stream/Stream.Ops repeatEffectWithSchedule */ export function repeatEffectWithSchedule( effect: Effect, schedule: Schedule ): Stream { return Stream.fromEffect(effect.zip(schedule.driver)).flatMap( ([a, driver]) => Stream.succeed(a) + Stream.unfoldEffect(a, (a) => driver.next(a).foldEffect( (e) => Effect.succeed(e), () => effect.map((nextA) => Maybe.some([nextA, nextA] as const)) )) ) }