danyx23 / elm-uuid Goto Github PK
View Code? Open in Web Editor NEWGenerate and parse UUIDs in Elm
License: BSD 3-Clause "New" or "Revised" License
Generate and parse UUIDs in Elm
License: BSD 3-Clause "New" or "Revised" License
I looked at your code and it just uses 32 bits of randomness (because the seed of Random.PCG is a 32 bit int), if I'm not completely mistaken. This means that according to https://en.wikipedia.org/wiki/Birthday_attack#Mathematics if you generate 50,000 uuids you will have a 25% chance of a collision.
Would be great if there was an easy way to access window.crypto.getRandomValues()
.
Hi,
are you working on migrating this to Elm 0.19? Do you want a PR?
In some cases, you need to use an empty value (such as Nothing, empty string or list, etc.). There is a nil/empty UUID value [1], however, there is no simple way to create one using the library. It would be nice to have a simple function to create one.
nil : Uuid
nil =
Uuid "00000000-0000-0000-0000-000000000000"
I'm using UUIDs as keys in a Dict
. As it stands, Elm does not support sum types as Dict
keys, so I'm forced to convert those UUIDs to String
using the Uuid.fromString
function. But this is not sufficient because
"1A571A57-0000-4000-B000-000000000000" |> Uuid.fromString |> Uuid.toString
== "1A571A57-0000-4000-B000-000000000000"
-- and
"1a571a57-0000-4000-b000-000000000000" |> Uuid.fromString |> Uuid.toString
== "1a571a57-0000-4000-b000-000000000000"
so the capitalization is preserved (which in my case makes Dict
keys unequal which should be equal). But per RFC 4122:
Each field is treated as an integer and has its value printed as a
zero-filled hexadecimal digit string with the most significant
digit first. The hexadecimal values "a" through "f" are output as
lower case characters and are case insensitive on input.
So both inputs should produce 1a571a57-0000-4000-b000-000000000000
as output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.