Type alias CounterMode

CounterMode: {
    renew(counterSize, context): number;
}

An interface of objects to customize the initial counter value for each new timestamp.

Scru64Generator calls renew() to obtain the initial counter value when the timestamp field has changed since the immediately preceding ID. Types implementing this interface may apply their respective logic to calculate the initial counter value.

Type declaration

  • renew:function
    • Returns the next initial counter value of counterSize bits.

      Scru64Generator passes the counterSize (from 1 to 23) and other context information that may be useful for counter renewal. The returned value must be within the range of counterSize-bit unsigned integer.

      Parameters

      • counterSize: number
      • context: {
            nodeId: number;
            timestamp: number;
        }
        • nodeId: number
        • timestamp: number

      Returns number