This package is an Elm implementation of ai/nanoid.
Features of this nanoid package are:
- Generator using elm/random
- Support for direct pool arguments using something like elm-random-pcg-extended
- Customizable alphabet and ID size
elm install MichaelCombs28/elm-nanoid
import Nanoid
import Random
...
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
GenerateNanoid ->
(model, Random.generate NanoidGenerated Nanoid.generator)
For more complete examples, see the examples folder.
See comparison of Nano ID and UUID(V4):
"Nano ID is quite comparable to UUID v4 (random-based). It has a similar number of random bits in the ID (126 in Nano ID and 122 in UUID), so it has a similar collision probability -- for there to be a one in a billion chance of duplication, 103 trillion version 4 IDs must be generated"
With Elm, there are always randomness concerns which is the cost for reliability. Flags generated with a few bytes of randomness passed to a decent PCG library should cover most usecases.