Class IdSortable<T>

Sortable ID generator based on UUIDv7 with millisecond resolution 36 bits of unixts enables timestamps of 2177.59 years from 1970 (2*36)/(1606024*365.25) ~= 2177.59 years Which means it will work until the year 4147 12 bits seq enables 4096 ids per millisecond After 4096, it rolls over

Type Parameters

Hierarchy

  • IdSortable

Implements

  • IterableIterator<T>

Constructors

  • Type Parameters

    Parameters

    • __namedParameters: {
          lastId?: Uint8Array;
          nodeId?: Uint8Array;
          randomSource?: ((size: number) => Uint8Array);
          timeSource?: ((lastTs?: number) => (() => number));
      } = {}
      • Optional lastId?: Uint8Array
      • Optional nodeId?: Uint8Array
      • Optional randomSource?: ((size: number) => Uint8Array)
          • (size: number): Uint8Array
          • Parameters

            • size: number

            Returns Uint8Array

      • Optional timeSource?: ((lastTs?: number) => (() => number))
          • (lastTs?: number): (() => number)
          • Parameters

            • Optional lastTs: number

            Returns (() => number)

              • (): number
              • Returns number

    Returns IdSortable<T>

Properties

_lastId?: T
clock: (() => number)

Type declaration

    • (): number
    • Returns number

lastTs?: [number, number]
nodeBits?: string
randomSource: ((size: number) => Uint8Array)

Type declaration

    • (size: number): Uint8Array
    • Parameters

      • size: number

      Returns Uint8Array

seqCounter: number

Accessors

Methods

  • Returns IterableIterator<T>

  • Returns IteratorResult<T, void>

Generated using TypeDoc