lanyard

A small, simple implementation of NanoID for Gleam, which is 100% dependency free! Not even bringing in the standard library!

Should work (and has been tested on) Erlang, JS in the browser, NodeJS 11+, Bun, and Deno.

Package Version Hex Docs

gleam add lanyard@1
import lanyard.{NanoID}

pub fn main() {
    let NanoID(my_new_id) = lanyard.new()
    echo my_new_id // A default, 21 character long NanoID

    let NanoID(my_short_id) = lanyard.custom_length(8)
    echo my_short_id // A shorter, 8 character long NanoID 
}

Further documentation can be found at https://hexdocs.pm/lanyard.

Development

gleam test  # Run the tests
Search Document