View Source Fast.Map (Fast v0.9.0)
Link to this section Summary
Functions
Like Enum.map/2
, but takes a map as the first arg instead of a list, and
a path of keys down to the list to which the mapping func should be applied.
Link to this section Functions
@spec deep_map(map(), nonempty_maybe_improper_list(), (... -> any())) :: map()
Like Enum.map/2
, but takes a map as the first arg instead of a list, and
a path of keys down to the list to which the mapping func should be applied.
example
Example:
data = %{
"groups" => [
%{
"elements" => [
%{"type" => "text"}
]
}
]
}
# Updates all the elements in the data
Fast.Map.deep_map(data, ["groups", "elements"], fn element ->
element
|> Map.put("kind", element["kind"])
|> Map.delete("type")
end)