API reference › @evolu/common › Schedule › delays
function delays<Output, Input>(
schedule: Schedule<Output, Input>,
): Schedule<
number &
Brand<"NonNaN"> &
Brand<"Finite"> &
Brand<"Int"> &
Brand<"NonNegative"> &
Brand<"LessThan281474976710655"> &
Brand<"Millis">,
Input
>;
Defined in: packages/common/src/Schedule.ts:1609
Outputs the delay between recurrences.
Wraps a schedule to output its delay (in milliseconds) instead of the original output. Useful for monitoring or logging delay patterns.
Exposing and observing delays
import {
assertEqual,
assertOk,
delays,
exponential,
tapScheduleOutput,
testCreateDeps,
type Millis,
} from "@evolu/common";
// Expose delays for monitoring, or observe them without changing output.
const monitorDelays = delays(exponential("100ms"));
const observed: Array<Millis> = [];
const logged = tapScheduleOutput((delay: Millis) => {
observed.push(delay);
})(delays(exponential("100ms")));
const deps = testCreateDeps();
assertOk(monitorDelays(deps)(undefined), [100, 100]);
assertOk(logged(deps)(undefined), [100, 100]);
assertEqual(observed, [100]);