MapRewire <~>: Syntactic sugar to quickly bulk rekey maps
Simple sugar to make changing keys on maps less ugly.
What’s the why? When you consume information from a lot of API’s/sources, you get data streaming in with the keys from other applications, other applications naming conventions might not fit your app.
left <~> right
, left
is your map from outside your app, right
is the rewrite rules.
It looks a little something like this: %{“id”=>”234923409”, “title”=>”asdf”}<~>[“title=>name”, “id=>shopify_id”]
Rewrite rules can be an Elixir List or a whitespace-separated list. They follow a format of left=>right
, left is the old key, and right representing the new.
Add it as a dep: {:map_rewire, “~> 0.1.0”}