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

Function fromDelays

packages/effect/src/internal/schedule.ts:801–828  ·  view source on GitHub ↗
(
  delay: Duration.DurationInput,
  ...delays: Array<Duration.DurationInput>
)

Source from the content-addressed store, hash-verified

799
800/** @internal */
801export const fromDelays = (
802 delay: Duration.DurationInput,
803 ...delays: Array<Duration.DurationInput>
804): Schedule.Schedule<Duration.Duration> =>
805 makeWithState(
806 [[delay, ...delays].map((_) => Duration.decode(_)) as Array<Duration.Duration>, true as boolean] as const,
807 (now, _, [durations, cont]) =>
808 core.sync(() => {
809 if (cont) {
810 const x = durations[0]!
811 const interval = Interval.after(now + Duration.toMillis(x))
812 if (durations.length >= 2) {
813 return [
814 [durations.slice(1), true] as const,
815 x,
816 ScheduleDecision.continueWith(interval)
817 ] as const
818 }
819 const y = durations.slice(1)
820 return [
821 [[x, ...y] as Array<Duration.Duration>, false] as const,
822 x,
823 ScheduleDecision.continueWith(interval)
824 ] as const
825 }
826 return [[durations, false] as const, Duration.zero, ScheduleDecision.done] as const
827 })
828 )
829
830/** @internal */
831export const fromFunction = <A, B>(f: (a: A) => B): Schedule.Schedule<B, A> => map(identity<A>(), f)

Callers

nothing calls this directly

Calls 4

makeWithStateFunction · 0.85
decodeMethod · 0.80
syncMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected