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

Function fromDelays

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

Source from the content-addressed store, hash-verified

791
792/** @internal */
793export const fromDelays = (
794 delay: Duration.DurationInput,
795 ...delays: Array<Duration.DurationInput>
796): Schedule.Schedule<Duration.Duration> =>
797 makeWithState(
798 [[delay, ...delays].map((_) => Duration.decode(_)) as Array<Duration.Duration>, true as boolean] as const,
799 (now, _, [durations, cont]) =>
800 core.sync(() => {
801 if (cont) {
802 const x = durations[0]!
803 const interval = Interval.after(now + Duration.toMillis(x))
804 if (durations.length >= 2) {
805 return [
806 [durations.slice(1), true] as const,
807 x,
808 ScheduleDecision.continueWith(interval)
809 ] as const
810 }
811 const y = durations.slice(1)
812 return [
813 [[x, ...y] as Array<Duration.Duration>, false] as const,
814 x,
815 ScheduleDecision.continueWith(interval)
816 ] as const
817 }
818 return [[durations, false] as const, Duration.zero, ScheduleDecision.done] as const
819 })
820 )
821
822/** @internal */
823export 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…