[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Schedule](https://evolu.dev/docs/api-reference/common/Schedule) › compensate

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

Defined in: [packages/common/src/Schedule.ts:1111](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Schedule.ts#L1111)

Adjusts delay by subtracting time elapsed beyond the previously returned
delay.

In a normal executor loop, this corresponds to the previous execution time.
If the runtime wakes later than requested, the extra lag is also compensated.
If execution and lag took longer than the delay, returns 0.

When composing with delay-shaping combinators such as [maxDelay](https://evolu.dev/docs/api-reference/common/Schedule/functions/maxDelay), put
`compensate` near the outside of the stack so it observes the final returned
delay.

For window-aligned scheduling, use [fixed](https://evolu.dev/docs/api-reference/common/Schedule/functions/fixed) instead.

### Compensating for execution time

```ts

const fastDeps = testCreateDeps();
const fastStep = compensate(spaced("5s"))(fastDeps);
assertOk(fastStep(undefined), [5000, 5000]);
// Five seconds waiting plus one second working leaves four seconds.
fastDeps.time.advance("6s");
assertOk(fastStep(undefined), [5000, 4000]);

const slowDeps = testCreateDeps();
const slowStep = compensate(spaced("5s"))(slowDeps);
assertOk(slowStep(undefined), [5000, 5000]);
// Five seconds waiting plus six seconds working leaves no delay.
slowDeps.time.advance("11s");
assertOk(slowStep(undefined), [5000, 0]);
```