An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

mapz



continous integration


hex.pm version


hex.pm license


erlang versions


Function Reference



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