View Source Numscriptex.Utilities (numscriptex v0.2.2)

Numscriptex.Utilities module contain reusable code that are common in more than one module of this library.

Summary

Functions

Convert map keys to the desired type. Can go from string to atom and vice versa.

Functions

normalize_keys(map, atom)

@spec normalize_keys(map(), :string | :atom) :: map()

Convert map keys to the desired type. Can go from string to atom and vice versa.

iex> map = %{"foo" => 100}
...> Utilities.normalize_keys(map, :atom)
%{foo: 100}

iex> map = %{foo: 100}
...> Utilities.normalize_keys(map, :string)
%{"foo" => 100}