General purpose helper functions for Localize.
Provides utility functions for checking empty data structures
and wrapping :persistent_term operations.
Summary
Functions
Returns a boolean indicating if a data structure is semantically empty.
Converts a string to an existing atom, returning nil if the atom
does not already exist in the atom table.
Functions
Returns a boolean indicating if a data structure is semantically empty.
Arguments
value— the value to check. Supported types are lists, maps, andnil.
Returns
trueif the value is an empty list, an empty map, ornil.falseotherwise.
Examples
iex> Localize.Utils.Helpers.empty?([])
true
iex> Localize.Utils.Helpers.empty?(%{})
true
iex> Localize.Utils.Helpers.empty?(nil)
true
iex> Localize.Utils.Helpers.empty?([1, 2])
false
iex> Localize.Utils.Helpers.empty?(%{a: 1})
false
Converts a string to an existing atom, returning nil if the atom
does not already exist in the atom table.
This is the safe alternative to String.to_existing_atom/1 that
avoids using try/rescue as control flow.
Arguments
stringis a binary string.
Returns
- The atom if it exists, or
nilotherwise.