message: extract loop from windowed
diff: @@ -1786,19 +1786,8 @@ export function whileOutputM_<S, Env, In, Out, S1, Env1>(
  return checkM_(self, (_, o) => T.map_(f(o), (b) => !b))
  }
  -/**
  - * A schedule that divides the timeline to `interval`-long windows, and sleeps
  - * until the nearest window boundary every time it recurs.
  - *
  - * For example, `windowed(10_000)` would produce a schedule as follows:
  - * <pre>
  - * 10s 10s 10s 10s
  - * |----------|----------|----------|----------|
  - * |action------|sleep---|act|-sleep|action----|
  - * </pre>
  - */
  -export function windowed(interval: number) {
  - function loop(
  +function windowedLoop(
  + interval: number,
  startMillis: O.Option<number>,
  n: number
  ): Decision.StepFunction<unknown, unknown, unknown, number> {
  @@ -1806,18 +1795,35 @@ export function windowed(interval: number) {
  T.succeed(
  O.fold_(
  startMillis,
  - () => Decision.makeContinue(n + 1, now + interval, loop(O.some(now), n + 1)),
  + () =>
  + Decision.makeContinue(
  + n + 1,
  + now + interval,
  + windowedLoop(interval, O.some(now), n + 1)
  + ),
  (startMillis) =>
  Decision.makeContinue(
  n + 1,
  now + ((now - startMillis) % interval),
  - loop(O.some(startMillis), n + 1)
  + windowedLoop(interval, O.some(startMillis), n + 1)
  )
  )
  )
  }
  - return new Schedule(loop(O.none, 0))
  +/**
  + * A schedule that divides the timeline to `interval`-long windows, and sleeps
  + * until the nearest window boundary every time it recurs.
  + *
  + * For example, `windowed(10_000)` would produce a schedule as follows:
  + * <pre>
  + * 10s 10s 10s 10s
  + * |----------|----------|----------|----------|
  + * |action------|sleep---|act|-sleep|action----|
  + * </pre>
  + */
  +export function windowed(interval: number) {
  + return new Schedule(windowedLoop(interval, O.none, 0))
  }
  function unfoldLoop<A>(
  