Fast.Map (Fast v0.11.0)
View SourceSummary
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.
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:
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)