Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cvik/maputils
Erlang map utilities
https://github.com/cvik/maputils
Last synced: about 2 months ago
JSON representation
Erlang map utilities
- Host: GitHub
- URL: https://github.com/cvik/maputils
- Owner: cvik
- License: apache-2.0
- Created: 2018-04-13T12:32:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T00:18:38.000Z (over 2 years ago)
- Last Synced: 2024-10-29T05:06:06.380Z (2 months ago)
- Language: Erlang
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Maputils - Utilities for erlang maps
## Exports
```erlang
deep_get(Keys, Map) -> Value
deep_put(Keys, Value, Map) -> Map
make_hierarchi(Order, Maps) -> Map
make_hierarchi(Order, Maps, dont_keep | keep) -> Map
```## Example usage
```erlang
1> l(maputils).
ok
2> maputils:deep_get(["1", "deep_key"], #{"1" => #{"deep_key" => "deep_value"}}).
"deep_value"
3> maputils:deep_put(["1", "2", "deep_key"], deep_value, #{}).
#{"1" => #{"2" => #{"deep_key" => deep_value}}}
4> maputils:make_hierarchi(["id", "2"],
[#{"id" => 1, "2" => 2, three => 3},
#{"id" => a, "2" => b, three => c},
#{"id" => x, "2" => y, three => z}]).
#{1 => #{2 => [#{three => 3}]},
a => #{b => [#{three => c}]},
x => #{y => [#{three => z}]}}
5> maputils:make_hierarchi(["id", "2"],
[#{"id" => 1, "2" => 2, three => 3},
#{"id" => a, "2" => b, three => c},
#{"id" => x, "2" => y, three => z}],
keep).
#{1 => #{2 => [#{three => 3,"2" => 2,"one" => 1}]},
a => #{b => [#{three => c,"2" => b,"one" => a}]},
x => #{y => [#{three => z,"2" => y,"one" => x}]}}
```## License
Apache license version 2.0. See the LICENSE file for details.