StrawHat v0.3.1 StrawHat.Utils.Map View Source
Functions for transforming maps, keys and values.
Link to this section Summary
Functions
Transforms a map
’s String.t
keys to atom()
keys
Transforms a map
’s String.t
values to atom()
values
Recursively traverse a map and invoke a function for each key/ value pair that transforms the map
Recursively traverse a map and invoke a function for each key and a function for each value that transform the map
Transforms a map
’s atom()
keys to String.t
keys
Link to this section Functions
Transforms a map
’s String.t
keys to atom()
keys.
map
is anyMap.t
options
is a keyword list of options. The available option is::only_existing
which is set totrue
will only convert the binary key to an atom if the atom already exists. The default isfalse
.
Transforms a map
’s String.t
values to atom()
values.
map
is anyMap.t
options
is a keyword list of options. The available option is::only_existing
which is set totrue
will only convert the binary value to an atom if the atom already exists. The default isfalse
.
Recursively traverse a map and invoke a function for each key/ value pair that transforms the map.
Arguments
map
is anyMap.t
function
is a function or function reference that is called for each key/value pair of the provided map
Returns
- The
map
transformed by the recursive application offunction
Example
iex> map = %{a: “a”, b: %{c: “c”}} iex> RobinCare.Web.Map.deep_map map, fn {k, v} -> …> {k, String.upcase(v)} …> end %{a: “A”, b: %{c: “C”}}
Recursively traverse a map and invoke a function for each key and a function for each value that transform the map.
map
is anyMap.t
key_function
is a function or function reference that is called for each key of the provided map and any keys of any submapsvalue_function
is a function or function reference that is called for each value of the provided map and any values of any submaps
Returns:
- The
map
transformed by the recursive application ofkey_function
andvalue_function