go-uuid icon indicating copy to clipboard operation
go-uuid copied to clipboard

Typescript implementation

Open holtwick opened this issue 4 years ago • 1 comments

I love the idea of a sortable UUID and wrote a port for Typescript for it. Especially the base62 is tricky, hope I got it right ;)

See here described as suid: https://github.com/holtwick/zeed#uuid

Implementation starts here: https://github.com/holtwick/zeed/blob/master/src/common/uuid.ts#L70

~~Did choose another reference date, probably should align it to yours.~~ - fixed

Adding a link to the implementation in your Readme if you like it, would be kind. Thanks.

holtwick avatar Jul 03 '21 22:07 holtwick

BTW: If you create a batch of UUIDs it may happen they have been created in the same millisecond. Then the sort order might not be correct anymore depending on the random part ;)

const s1 = suid()
const s2 = suid()
s1 < s2 // might become false

A smart implementation could remember the last timestamp and delay uuid creation if it is the same as the previous one. This might help for local conflicts at least.

holtwick avatar Jul 03 '21 23:07 holtwick