Creates a generator object with the default random number generator, or with the specified one if passed as an argument. The specified random number generator should be cryptographically strong and securely seeded.
OptionalrandomNumberGenerator: { nextUint32(): number }Returns a 32-bit random unsigned integer.
Generates a new UUIDv7 object from the current timestamp, or resets the generator upon significant timestamp rollback.
This method returns a monotonically increasing UUID by reusing the previous timestamp even if the up-to-date timestamp is smaller than the immediately preceding UUID's. However, when such a clock rollback is considered significant (by default, more than ten seconds), this method resets the generator and returns a new UUID based on the given timestamp, breaking the increasing order of UUIDs.
See generateOrAbort for the other mode of generation and generateOrResetWithTs for the variant accepting a custom timestamp.
Generates a new UUIDv7 object from the current timestamp, or returns
undefined upon significant timestamp rollback.
This method returns a monotonically increasing UUID by reusing the previous
timestamp even if the up-to-date timestamp is smaller than the immediately
preceding UUID's. However, when such a clock rollback is considered
significant (by default, more than ten seconds), this method aborts and
returns undefined immediately.
See generate for the other mode of generation and generateOrAbortWithTs for the variant accepting a custom timestamp.
Generates a new UUIDv7 object from the unixTsMs passed, or returns
undefined upon significant timestamp rollback.
This method is a deprecated version of generateOrAbortWithTs that
accepts the rollbackAllowance parameter as an argument, rather than using
the generator-level parameter.
The amount of unixTsMs rollback that is
considered significant. A suggested value is 10_000 (milliseconds).
Since v1.2.0. Use generateOrAbortWithTs instead.
Generates a new UUIDv7 object from the unixTsMs passed, or returns
undefined upon significant timestamp rollback.
This method is equivalent to generateOrAbort except that it takes a custom timestamp.
Generates a new UUIDv7 object from the unixTsMs passed, or resets the
generator upon significant timestamp rollback.
This method is a deprecated version of generateOrResetWithTs that
accepts the rollbackAllowance parameter as an argument, rather than using
the generator-level parameter.
The amount of unixTsMs rollback that is
considered significant. A suggested value is 10_000 (milliseconds).
Since v1.2.0. Use generateOrResetWithTs instead.
Sets the rollbackAllowance parameter of the generator.
The rollbackAllowance parameter specifies the amount of unixTsMs
rollback that is considered significant. The default value is 10_000
(milliseconds). See the generate or generateOrAbort
documentation for the treatment of the significant rollback.
Encapsulates the monotonic counter state.
This class provides APIs to utilize a separate counter state from that of the global generator used by uuidv7 and uuidv7obj. In addition to the default generate method, this class has generateOrAbort that is useful to absolutely guarantee the monotonically increasing order of generated UUIDs. See their respective documentation for details.