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

Function exponential

packages/effect/src/Schedule.ts:850–859  ·  view source on GitHub ↗
(
  base: Duration.Input,
  factor: number = 2
)

Source from the content-addressed store, hash-verified

848 * @since 2.0.0
849 */
850export const exponential = (
851 base: Duration.Input,
852 factor: number = 2
853): Schedule<Duration.Duration> => {
854 const baseMillis = Duration.toMillis(Duration.fromInputUnsafe(base))
855 return fromStepWithMetadata(effect.succeed((meta) => {
856 const duration = Duration.millis(baseMillis * Math.pow(factor, meta.attempt - 1))
857 return effect.succeed([duration, duration])
858 }))
859}
860
861/**
862 * Schedule that always recurs, increasing delays by summing the preceding

Callers

nothing calls this directly

Calls 2

fromStepWithMetadataFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected