API reference@evolu/commonSchedule › compensate

function compensate<Output, Input>(
  schedule: Schedule<Output, Input>,
): Schedule<Output, Input>;

Defined in: packages/common/src/Schedule.ts:781

Adjusts delay by subtracting execution time.

A simple combinator that subtracts the previous execution time from the schedule's delay. If execution took longer than the delay, returns 0.

For window-aligned scheduling, use fixed instead.

Example

// Poll every 5s, accounting for execution time
const polling = compensate(spaced("5s"));
// If poll takes 1s → wait 4s. If poll takes 6s → wait 0s.