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

Function min

packages/effect/src/Schedule.ts:783–815  ·  view source on GitHub ↗
(
  schedules: Schedules
)

Source from the content-addressed store, hash-verified

781 * @since 4.0.0
782 */
783export const min = <
784 const Schedules extends NonEmptyReadonlyArray<
785 Schedule<any, any, any, any>
786 >
787>(
788 schedules: Schedules
789): Schedule<
790 Duration.Duration,
791 UnionToIntersection<
792 Input<Schedules[number]>
793 >,
794 Error<Schedules[number]>,
795 Env<Schedules[number]>
796> =>
797 fromStep(effect.map(
798 effect.all(schedules.map(toStep)),
799 (steps) => (now, input) =>
800 effect.flatMap(
801 effect.forEach(steps, (step) =>
802 Pull.matchEffect(step(now, input as never), {
803 onSuccess: (result) => effect.succeed(result[1]),
804 onDone: () => effect.undefined,
805 onFailure: effect.failCause
806 })),
807 (results) => {
808 const duration = minDuration(results)
809 if (duration === undefined) {
810 return Cause.done(Duration.zero)
811 }
812 return effect.succeed([duration, duration] as [Duration.Duration, Duration.Duration])
813 }
814 )
815 ))
816
817const minDuration = (results: ReadonlyArray<Duration.Duration | undefined>): Duration.Duration | undefined => {
818 let min: Duration.Duration | undefined = undefined

Callers

nothing calls this directly

Calls 8

fromStepFunction · 0.85
minDurationFunction · 0.85
allMethod · 0.80
stepFunction · 0.70
forEachMethod · 0.65
mapMethod · 0.45
succeedMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected