https://github.com/eproxus/mapz
Additions to the Erlang maps module
https://github.com/eproxus/mapz
Last synced: 8 months ago
JSON representation
Additions to the Erlang maps module
- Host: GitHub
- URL: https://github.com/eproxus/mapz
- Owner: eproxus
- License: mit
- Created: 2014-12-17T13:27:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2025-02-14T18:26:13.000Z (over 1 year ago)
- Last Synced: 2025-03-18T04:42:51.870Z (about 1 year ago)
- Language: Erlang
- Size: 120 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
mapz
`mapz` contains additions to the Erlang maps module, mostly functionality to
nested map usage. It tries to stay as true as possible to the original `maps`
API with the same or similar errors where applicable.
## Features
### Deep Access
#### Getting & Setting
```erlang
1> Map = #{a => #{big => #{nested => #{map => with},some => values},
.. in => it,like => "hello"}}.
#{a =>
#{big => #{nested => #{map => with},some => values},
in => it,like => "hello"}}
2> mapz:deep_get([a, big, nested, map], Map).
with
3> mapz:deep_search([a, big, nested, list], Map).
{error,[a,big,nested],#{map => with}}
4> mapz:deep_remove([a, like], Map).
#{a =>
#{big => #{nested => #{map => with},some => values},
in => it}}
```
#### Merging
```erlang
5> NewMap = mapz:deep_merge(Map, #{a => #{big => #{nested => #{list => [1,2,3]}}}}).
#{a =>
#{big =>
#{nested => #{list => [1,2,3],map => with},some => values},
in => it,like => "hello"}}
6> mapz:deep_search([a, big, nested, list], NewMap).
{ok,[1,2,3]}
```
#### Inverse
```erlang
1> mapz:inverse(#{a => 1, b => 2, c => 3}).
#{1 => a,2 => b,3 => c}
```