automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.76k stars 467 forks source link

Nanoid usage #451

Closed steida closed 2 years ago

steida commented 2 years ago

I see Nanoid in package.json, but not in the code. Is there any plan to use it instead of src/uuid.js?

The reason why I am asking is I am using (Base58 based) NanoID because I expect IDs will be shared via URL etc. Base 58 makes Nanoid even nicer.

ept commented 2 years ago

Where in package.json do you see nanoid? I only see it as an indirect dependency of mocha.

If we replace UUID with anything, I would just replace it with Crypto.getRandomValues(). Internally the actor IDs are encoded as binary; the hex representation is only used when we need a human-readable string in the API. Hex has the advantage that when hex strings are sorted lexicographically, the order is the same as if the raw byte strings were sorted; we rely on this property in a few places. I don't think Base58 has this property, so for this reason I want to stick with hex.

steida commented 2 years ago

Not package.json, yarn.lock, sorry. OK, thank you.