API reference › @evolu/common › Schedule › fibonacci
function fibonacci(
initial: Duration,
): Schedule<
number &
Brand<"NonNaN"> &
Brand<"Finite"> &
Brand<"Int"> &
Brand<"NonNegative"> &
Brand<"LessThan281474976710655"> &
Brand<"Millis">
>;
Defined in: packages/common/src/Schedule.ts:381
Fibonacci backoff schedule.
Delays follow the Fibonacci sequence, growing more slowly than exponential:
- Step 1:
initial - Step 2:
initial - Step 3:
initial * 2 - Step 4:
initial * 3 - Step 5:
initial * 5 - ...
Never stops — combine with take or maxElapsed to limit.
Fibonacci growth
import { assertOk, fibonacci, testCreateDeps } from "@evolu/common";
// 100ms, 100ms, 200ms, 300ms, 500ms, ...
const step = fibonacci("100ms")(testCreateDeps());
assertOk(step(undefined), [100, 100]);
assertOk(step(undefined), [100, 100]);
assertOk(step(undefined), [200, 200]);