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

Function intersectWithLoop

packages/effect/src/internal/schedule.ts:938–1007  ·  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

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