ulid / javascript

Universally Unique Lexicographically Sortable Identifier
MIT License
3.04k stars 107 forks source link

Monotonically Increasing Guarantee #74

Open rrichardson opened 4 years ago

rrichardson commented 4 years ago

This is related to https://github.com/ulid/javascript/issues/21 and https://github.com/ulid/spec/issues/11

If multiple UUIDs are generated in the same millisecond, the random bits are not guaranteed to be monotonically increasing. So given const [a, b, c] = [ulid(), ulid(), ulid()]
c and b could sort lower than a

This implementation already has an algo for incrementing the base32 of the ulid. It should just change to increment the most significant bits instead of the least significant bits of the random portion.