Packages
iteraptor
0.4.0
1.15.0
1.14.0
1.13.1
1.13.0
1.12.2
1.12.1
1.12.0
1.11.0
1.10.3
1.10.2
1.10.1
1.9.0
1.8.0
1.7.3
1.7.2
1.7.1
1.7.0
1.6.1
1.6.0
1.4.1
1.4.0
1.3.2
1.2.1
1.2.0
1.1.1
1.1.0
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc1
0.7.0
0.6.2
0.6.1
0.5.2
0.5.1
0.5.0
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.4
0.2.3
0.2.2
0.2.1
0.1.1
0.1.0
This small library allows the deep iteration / mapping of Enumerables.
Current section
Files
Jump to
Current section
Files
README.md
# Iteraptor
[](https://travis-ci.org/am-kantox/elixir-iteraptor)
[](http://inch-ci.org/github/am-kantox/elixir-iteraptor)
[](https://beta.hexfaktor.org/github/am-kantox/elixir-iteraptor)
Handy enumerable operations:
* `to_flatmap`
## Installation
1. Add `iteraptor` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:iteraptor, "~> 0.3.0"}]
end
```
2. Ensure `iteraptor` is started before your application:
```elixir
def application do
[applications: [:iteraptor]]
end
```
## Usage
```elixir
iex> %{a: %{b: %{c: 42, d: [nil, 42]}, e: [:f, 42]}} |> Iteraptor.to_flatmap
%{"a.b.c" => 42, "a.b.d.0" => nil, "a.b.d.1" => 42, "a.e.0" => :f, "a.e.1" => 42}
```
To be implicitly as explicit as possible, the current implementation creates
string keys for those, containing joiner and atoms for those that haven’t.
That makes normal maps to be resistant to
```elixir
iex> %{a: %{b: %{c: 42}}} |> Iteraptor.to_flatmap |> Iteraptor.from_flatmap
%{a: %{b: %{c: 42}}}
```
## Changelog
As of version `0.3.0`, the module supports
[`Keyword`](http://elixir-lang.org/docs/stable/elixir/Keyword.html) on input,
but it will be output as map for `|> Iteraptor.to_flatmap |> Iteraptor.from_flatmap`
back and forth transformation.
As of version `0.4.0`, the module supports
[structs](http://elixir-lang.org/getting-started/structs.html) on input.
Structs will be automagically created on `|> Iteraptor.from_flatmap` from
keys like `StructName%field` if a) this structure is known to the system
and b) keys are consistent (e. g. there are no subsequent elements,
belonging to different structs: `["S1%f" => 42, "S2%f" => 3.14]`.)
Please see examples for an inspiration.