Closed jampy closed 6 years ago
I get the idea. Willing to look at a PR. I don't like the idea of using anything but the most rudimentary fast hashing algorithm (like, something that could be implemented in less than 10 LOC). cuid should remain a tiny dependency.
Also, I'd prefer not to use try/catch. We can check for feature availability without slowing things down with error catching.
While we're at it, we could use feature detection to eliminate the separate build for Node. Game on!
Okay, will think about a PR once I get some time perhaps (at the moment I'm using shortid)
As for the try/catch: AFAIK the fingerprint()
function is only executed once, so I don't think speed is relevant.
Good point.
This should be fixed now. Reopen if you still have trouble.
Please add support for web workers.
cuid()
currently throws an exception in web workers sincenavigator.mimeTypes
is not available in that context.Generally, for the fingerprint I suggest to collect various strings as a whole, gracefully handling errors, and then create a fingerprint out of that (arbitrary length) string using some hash function - like MD5, but perhaps something more lightweight.
Something in this direction:
I think you get the idea...