Function backoffGenerator

  • Generates an expoential backoff series of values

    // Default: start at 1, power 1.1
    for (const v of backoffGenerator()) {
    // v: numeric value
    }

    By default the generator runs forever. Use either limitAttempts or limitValue to stop it when it produces a given quantity of values, or when the value itself reaches a threshold.

    For example:

    // `values` will have five values in it
    const values = [...backoffGenerator({ limitAttempts: 5 })];
    // Keep generating values until max is reached
    const values = [...backoffGenerator({ limitValue: 1000 })];

    Options:

    • startAt: start value
    • limitAttempts: cap the number of values to generate
    • limitValue: cap the maximum calculated value
    • power: power value (default 1.1)

    Parameters

    Returns Generator<number, void, unknown>