MCPcopy Index your code
hub / github.com/Effect-TS/effect / intersectWithLoop

Function intersectWithLoop

packages/effect/src/internal/schedule.ts:930–999  ·  view source on GitHub ↗
(
  self: Schedule.Schedule<Out, In, Env>,
  that: Schedule.Schedule<Out2, In1, Env1>,
  input: In & In1,
  lState: State,
  out: Out,
  lInterval: Intervals.Intervals,
  rState: State1,
  out2: Out2,
  rInterval: Intervals.Intervals,
  f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals
)

Source from the content-addressed store, hash-verified

928
929/** @internal */
930const intersectWithLoop = <State, State1, Env, In, Out, Env1, In1, Out2>(
931 self: Schedule.Schedule<Out, In, Env>,
932 that: Schedule.Schedule<Out2, In1, Env1>,
933 input: In & In1,
934 lState: State,
935 out: Out,
936 lInterval: Intervals.Intervals,
937 rState: State1,
938 out2: Out2,
939 rInterval: Intervals.Intervals,
940 f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals
941): Effect.Effect<
942 [[State, State1], [Out, Out2], ScheduleDecision.ScheduleDecision],
943 never,
944 Env | Env1
945> => {
946 const combined = f(lInterval, rInterval)
947 if (Intervals.isNonEmpty(combined)) {
948 return core.succeed([
949 [lState, rState],
950 [out, out2],
951 ScheduleDecision.continue(combined)
952 ])
953 }
954
955 if (pipe(lInterval, Intervals.lessThan(rInterval))) {
956 return core.flatMap(self.step(Intervals.end(lInterval), input, lState), ([lState, out, decision]) => {
957 if (ScheduleDecision.isDone(decision)) {
958 return core.succeed([
959 [lState, rState],
960 [out, out2],
961 ScheduleDecision.done
962 ])
963 }
964 return intersectWithLoop(
965 self,
966 that,
967 input,
968 lState,
969 out,
970 decision.intervals,
971 rState,
972 out2,
973 rInterval,
974 f
975 )
976 })
977 }
978 return core.flatMap(that.step(Intervals.end(rInterval), input, rState), ([rState, out2, decision]) => {
979 if (ScheduleDecision.isDone(decision)) {
980 return core.succeed([
981 [lState, rState],
982 [out, out2],
983 ScheduleDecision.done
984 ])
985 }
986 return intersectWithLoop(
987 self,

Callers 1

schedule.tsFile · 0.85

Calls 4

pipeFunction · 0.70
stepMethod · 0.65
endMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected