https://github.com/byjpr/maprewire
Syntactic sugar to bulk rekey maps
https://github.com/byjpr/maprewire
elixir elixir-lang elixir-language elixir-library hex json macros maps
Last synced: 2 months ago
JSON representation
Syntactic sugar to bulk rekey maps
- Host: GitHub
- URL: https://github.com/byjpr/maprewire
- Owner: byjpr
- License: mit
- Created: 2018-08-20T19:12:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-30T14:58:41.000Z (almost 3 years ago)
- Last Synced: 2025-04-08T16:17:47.955Z (10 months ago)
- Topics: elixir, elixir-lang, elixir-language, elixir-library, hex, json, macros, maps
- Language: Elixir
- Homepage: https://hex.pm/packages/map_rewire
- Size: 117 KB
- Stars: 7
- Watchers: 0
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MapRewire
[](https://github.com/byjpr/MapRewire/actions/workflows/elixir.yml)
[](https://coveralls.io/github/byjord/MapRewire)
[](https://libraries.io/hex/map_rewire)
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
```elixir
def deps do
[
{:map_rewire, "~> 0.3.0"}
]
end
```
## Contributors
| [](https://github.com/byjord) | [](https://github.com/halostatue) |
| :-----------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: |
| [byjord](https://github.com/byjord) | [halostatue](https://github.com/halostatue) |