This library can be used to generate [nanoids][nanoid] in elm, which can be more URL friendly than UUIDs.
Nanoid type. Represents a generated nanoid.
nanoid : List Basics.Int -> Nanoid
Creates a nanoid from a given list of integers. Generally you want to create
a randomness pool in JS using something like Array.from(crypto.getRandomValues(new Uint8Array(21*21*7)))
.
See the examples on how to do this properly. Most nanoids consist of 21 bytes.
nanoid [ 0, 1, 2 ] == "abc"
The length of the pool determines the length of the output.
generator : Random.Generator Nanoid
Generate nanoids using the standard values and elm/random
import Random
import Nanoid exposing (Nanoid)
Random.step Nanoid.generator (Random.initialSeed 0) == "qBrbY8E1PkuPSRjijxsab"
nanoidWithOptions : Array Char -> List Basics.Int -> Nanoid
Generate a nanoid using a custom charmap.
import Array
nanoidWithOptions (Array.fromList ['a', 'b', 'c', 'd']) [1, 2, 3] == "abc"
toString : Nanoid -> String
String representation of a nanoid.