Fox.DictExt

Source

Summary

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

is_blank(arg1)
Source
key_map(dict, f)

Specs:

Maps over the keys of a dict while leaving the values alone

Examples

%{"dog_food" => 3} |> key_map(&StringExt.camelize/1)
# %{"DogFood" => 3}
Source
reject_blank_keys(dict)

Specs:

Takes a Dict and drops every key which has a blank value

Examples

%{dog: nil, cat: 4} |> reject_blank_keys
# %{cat: 4}
Source
shallowify_keys(map)

Specs:

Takes a possibly deeply nested dict, and “unnests” it

Examples

%{"dog" => %{"cat" => "rover"}} |> shallowify_keys
# [{"dog[cat]", "rover"}]
Source
value_map(dict, f)

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}
Source