Skip to content

byjpr/MapRewire

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapRewire

Elixir CI Coverage Status Libraries.io for releases

Bulk rekey your maps. Simple bud. (☞゚ ヮ ゚)☞

Why?

Simply because I am super lazy, and writing out functions to take maps and convert them to different keys was boring (and irritating) me.

Stop writing defp from_x_to_y(data), do: %{ "another_id" => data["id"], "name" => data["title"] }.

TL;DR; Syntax

  1. Macro: content<~>transformation, content is your data, transformation is your rules.
  2. Content: Any map. BYOD.
  3. Transformation: from=>to. Left is the original key, right is the new key.

Getting started

def deps do
  [
    {:map_rewire, "~> 0.3.0"}
  ]
end

Contributors

byjord halostatue
byjord halostatue