Nanoid.Configuration (Nanoid v3.0.0-rc.1)

Copy Markdown View Source

Configuration module used by NanoID generators to get the required configuration.

Summary

Functions

Returns the default alphabet of a nanoid used by the generators.

Returns the length of the default alphabet (in graphemes).

Returns the default alphabet as a precomputed tuple of graphemes, enabling O(1) symbol lookup at runtime.

Returns the default mask used by the secure generator.

Returns the default size of a nanoid used by the generators.

Functions

default_alphabet()

@spec default_alphabet() :: binary()

Returns the default alphabet of a nanoid used by the generators.

Example

iex> Nanoid.Configuration.default_alphabet()
"_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

default_alphabet_length()

@spec default_alphabet_length() :: non_neg_integer()

Returns the length of the default alphabet (in graphemes).

Example

iex> Nanoid.Configuration.default_alphabet_length()
64

default_alphabet_tuple()

@spec default_alphabet_tuple() :: tuple()

Returns the default alphabet as a precomputed tuple of graphemes, enabling O(1) symbol lookup at runtime.

default_mask()

@spec default_mask() :: non_neg_integer()

Returns the default mask used by the secure generator.

Example

iex> Nanoid.Configuration.default_mask()
63

default_size()

@spec default_size() :: non_neg_integer()

Returns the default size of a nanoid used by the generators.

Example

iex> Nanoid.Configuration.default_size()
21