Fox.DictExt
SourceSummary
is_blank(arg1) | |
key_map(dict, f) | Maps over the keys of a dict while leaving the values alone |
reject_blank_keys(dict) | Takes a Dict and drops every key which has a blank value |
shallowify_keys(map) | Takes a possibly deeply nested dict, and “unnests” it |
value_map(dict, f) | Maps over just the value of your map while keeping all the keys the same |
Functions
Specs:
Maps over the keys of a dict while leaving the values alone
Examples
%{"dog_food" => 3} |> key_map(&StringExt.camelize/1)
# %{"DogFood" => 3}
Specs:
Takes a Dict and drops every key which has a blank value
Examples
%{dog: nil, cat: 4} |> reject_blank_keys
# %{cat: 4}
Specs:
Takes a possibly deeply nested dict, and “unnests” it
Examples
%{"dog" => %{"cat" => "rover"}} |> shallowify_keys
# [{"dog[cat]", "rover"}]
Specs:
Maps over just the value of your map while keeping all the keys the same
Examples
%{dog: 1, cat: 2} |> value_map(&(&1 + 2))
# %{dog: 3, cat: 4}