{"id":18002868,"url":"https://github.com/am-kantox/elixir-iteraptor","last_synced_at":"2025-04-09T13:11:45.387Z","repository":{"id":55639266,"uuid":"67813706","full_name":"am-kantox/elixir-iteraptor","owner":"am-kantox","description":"Handy enumerable operations implementation.","archived":false,"fork":false,"pushed_at":"2025-03-03T05:21:13.000Z","size":211,"stargazers_count":72,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T03:35:25.514Z","etag":null,"topics":["elixir","elixir-lang","iteration","mapreduce"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/am-kantox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-09T16:13:59.000Z","updated_at":"2025-03-23T07:56:07.000Z","dependencies_parsed_at":"2022-08-15T05:10:39.357Z","dependency_job_id":null,"html_url":"https://github.com/am-kantox/elixir-iteraptor","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Felixir-iteraptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Felixir-iteraptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Felixir-iteraptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Felixir-iteraptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/am-kantox","download_url":"https://codeload.github.com/am-kantox/elixir-iteraptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589829,"owners_count":20963022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","elixir-lang","iteration","mapreduce"],"created_at":"2024-10-29T23:24:18.103Z","updated_at":"2025-04-09T13:11:45.364Z","avatar_url":"https://github.com/am-kantox.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iteraptor\n\n[![Build Status](https://travis-ci.org/am-kantox/elixir-iteraptor.svg?branch=master)](https://travis-ci.org/am-kantox/elixir-iteraptor)\n[![Inline docs](http://inch-ci.org/github/am-kantox/elixir-iteraptor.svg)](http://inch-ci.org/github/am-kantox/elixir-iteraptor)\n[![Hex.pm](https://img.shields.io/badge/hex-v.1.12.0-blue.svg?style=flat)](https://hex.pm/packages/iteraptor)\n\n### Handy enumerable operations\n\n  * [`Iteraptor.each/3`](https://hexdocs.pm/iteraptor/Iteraptor.html#each/3)\n    to iterate a deeply nested map/list/keyword;\n  * [`Iteraptor.map/3`](https://hexdocs.pm/iteraptor/Iteraptor.html#map/3)\n    to map a deeply nested map/list/keyword;\n  * [`Iteraptor.reduce/4`](https://hexdocs.pm/iteraptor/Iteraptor.html#reduce/4)\n    to reduce a deeply nested map/list/keyword;\n  * [`Iteraptor.map_reduce/4`](https://hexdocs.pm/iteraptor/Iteraptor.html#map_reduce/4)\n    to map and reduce a deeply nested map/list/keyword;\n  * [`Iteraptor.filter/3`](https://hexdocs.pm/iteraptor/Iteraptor.html#filter/3)\n    to filter a deeply nested map/list/keyword;\n  * [`Iteraptor.to_flatmap/2`](https://hexdocs.pm/iteraptor/Iteraptor.html#to_flatmap/2)\n    to flatten a deeply nested map/list/keyword into\n    flatten map with concatenated keys;\n  * [`Iteraptor.from_flatmap/3`](https://hexdocs.pm/iteraptor/Iteraptor.html#from_flatmap/3)\n    to “unveil”/“unflatten” the previously flattened map into nested structure;\n  * [`use Iteraptor.Iteraptable`](https://hexdocs.pm/iteraptor/Iteraptor.Iteraptable.html)\n    to automagically implement `Enumerable` and `Collectable` protocols, as well as\n    `Access` behaviour on the structure.\n\n**bonus:**\n\n  * [`Iteraptor.jsonify/2`](https://hexdocs.pm/iteraptor/Iteraptor.html#jsonify/2) to prepare the term for JSON interchange; it basically converts keys to strings and keywords to maps because JSON encoders might have issues with serializing keywords.\n\n  * [`Iteraptor.Extras.bury/4`](https://hexdocs.pm/iteraptor/Iteraptor.Extras.html#bury/4)\n    to store the value deeply inside nested term (the intermediate keys are created as\n    necessary.)\n\n### HexDocs\n\n  * [API Reference](https://hexdocs.pm/iteraptor/api-reference.html)\n  * [`Iteraptor`](https://hexdocs.pm/iteraptor/Iteraptor.html)\n  * [`Iteraptor.Iteraptable`](https://hexdocs.pm/iteraptor/Iteraptor.Iteraptable.html)\n\n### Usage\n\n#### Iterating, Mapping, Reducing\n\n```elixir\n# each\niex\u003e %{a: %{b: %{c: 42}}} |\u003e Iteraptor.each(\u0026IO.inspect/1, yield: :all)\n# {[:a], %{b: %{c: 42}}}\n# {[:a, :b], %{c: 42}}\n# {[:a, :b, :c], 42}\n%{a: %{b: %{c: 42}}}\n\n# map\niex\u003e %{a: %{b: %{c: 42}}} |\u003e Iteraptor.map(fn {k, _} -\u003e Enum.join(k) end)\n%{a: %{b: %{c: \"abc\"}}}\n\niex\u003e %{a: %{b: %{c: 42}}}\n...\u003e |\u003e Iteraptor.map(fn\n...\u003e      {[_], _} = self -\u003e self\n...\u003e      {[_, _], _} -\u003e \"YAY\"\n...\u003e    end, yield: :all)\n%{a: %{b: \"YAY\"}}\n\n# reduce\niex\u003e %{a: %{b: %{c: 42}}}\n...\u003e |\u003e Iteraptor.reduce([], fn {k, _}, acc -\u003e\n...\u003e      [Enum.join(k, \"_\") | acc]\n...\u003e    end, yield: :all)\n...\u003e |\u003e :lists.reverse()\n[\"a\", \"a_b\", \"a_b_c\"]\n\n# map-reduce\niex\u003e %{a: %{b: %{c: 42}}}\n...\u003e |\u003e Iteraptor.map_reduce([], fn\n...\u003e      {k, %{} = v}, acc -\u003e {{k, v}, [Enum.join(k, \".\") | acc]}\n...\u003e      {k, v}, acc -\u003e {{k, v * 2}, [Enum.join(k, \".\") \u003c\u003e \"=\" | acc]}\n...\u003e    end, yield: :all)\n{%{a: %{b: %{c: 42}}}, [\"a.b.c=\", \"a.b\", \"a\"]}\n\n# filter\niex\u003e %{a: %{b: 42, e: %{f: 3.14, c: 42}, d: %{c: 42}}, c: 42, d: 3.14}\n...\u003e |\u003e Iteraptor.filter(fn {key, _} -\u003e :c in key end, yield: :none)\n%{a: %{e: %{c: 42}, d: %{c: 42}}, c: 42}\n```\n\n#### Flattening\n\n```elixir\niex\u003e %{a: %{b: %{c: 42, d: [nil, 42]}, e: [:f, 42]}}\n...\u003e |\u003e Iteraptor.to_flatmap(delimiter: \"_\")\n#⇒ %{\"a_b_c\" =\u003e 42, \"a_b_d_0\" =\u003e nil, \"a_b_d_1\" =\u003e 42, \"a_e_0\" =\u003e :f, \"a_e_1\" =\u003e 42}\n\niex\u003e %{\"a.b.c\": 42, \"a.b.d.0\": nil, \"a.b.d.1\": 42, \"a.e.0\": :f, \"a.e.1\": 42}\n...\u003e |\u003e Iteraptor.from_flatmap\n#⇒ %{a: %{b: %{c: 42, d: [nil, 42]}, e: [:f, 42]}}\n```\n\n#### Extras\n\n```elixir\niex\u003e Iteraptor.jsonify([foo: [bar: [baz: :zoo], boo: 42]], values: true)\n%{\"foo\" =\u003e %{\"bar\" =\u003e %{\"baz\" =\u003e \"zoo\"}, \"boo\" =\u003e 42}}\n\niex\u003e Iteraptor.Extras.bury([foo: :bar], ~w|a b c d|a, 42)\n[a: [b: [c: [d: 42]]], foo: :bar]\n```\n\n**As of version `1.2.0` there is an experimental AST traversal feature:**\n\n```elixir\niex\u003e Iteraptor.AST.reduce((quote do: 42), [], fn e, acc -\u003e [e | acc], yield: :all)\n'*'\n```\n\n---\n\n### Installation\n\nAdd `iteraptor` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps, do: [{:iteraptor, \"~\u003e 1.5\"}]\n```\n\n\n### Changelog\n\n#### `1.14.0`\n\nUpdated dependecies to modern _Elixir_\n\n#### `1.13.0`\n\n`keys: :reverse` configuration option in all traversion functions to simplify pattern matching on leaf keys\n\n#### `1.10.0`\n\n`Iteraptor.jsonify/2` for deep conversion of keyword lists to maps.\n\n#### `1.8.0`\n\n`Iteraptor.Config` for deep substitution of `{:system, \"VAR\"}` tuples with the\n  values taken from the system environment in runtime.\n\n#### `1.7.0`\n\n`Iteraptor.Array` with `Access` support. Basically, `Array` is the list with `Access` support.\n\n- `1.7.2` → fixed bug with type recognition for `MapSet` and `Iteraptor.Array`.\n\n#### `1.6.0`\n\n`Iteraptor.jsonify/2`.\n\n#### `1.5.0`\n\nAll iterators do now accept `structs: :values` keyword argument to prevent nested iteration into structs.\n\nExperimental support for `Iteraptable` protocol.\n\n#### `1.4.0`\n\nExtended support for `Iteraptor.Iteraptable`:\n\n#### `1.3.0`\n\nWe now support `MapSet`s.\n\n#### `1.0.0-rc1`\n\nBetter documentation, `Iteraptor.Extras.bury/3`.\n\n#### `0.9.0`\n\nComplete refactoring, `Iteraptor.map/3`, `Iteraptor.reduce/4`, `Iteraptor.map_reduce/4`.\n\n#### `0.5.0`\n\n**NB:** This functionality is experimental and might not appear in `1.0.0` release.\n\n`use Iteraptor.Iteraptable` inside structs to make them both\n[`Enumerable`](http://elixir-lang.org/docs/stable/elixir/Enumerable.html) and\n[`Collectable`](http://elixir-lang.org/docs/stable/elixir/Collectable.html):\n\n```elixir\ndefmodule Iteraptor.Struct do\n  @fields [field: nil]\n\n  def fields, do: @fields\n  defstruct @fields\n\n  use Iteraptor.Iteraptable\nend\n\niex\u003e %Iteraptor.Struct{field: 42}\n...\u003e   |\u003e Enum.each(fn e -\u003e IO.inspect(e) end)\n#⇒   {:field, 42}\n```\n\n#### `0.4.0`\n\n_Experimental:_ support for [structs](http://elixir-lang.org/getting-started/structs.html) on input.\nStructs will be automagically created on `|\u003e Iteraptor.from_flatmap` from\nkeys like `StructName%field` if a) this structure is known to the system\nand b) keys are consistent (e. g. there are no subsequent elements,\nbelonging to different structs: `[\"S1%f\" =\u003e 42, \"S2%f\" =\u003e 3.14]`.)\n\n#### `0.3.0`\n\nSupport for [`Keyword`](http://elixir-lang.org/docs/stable/elixir/Keyword.html) on input,\nbut it will be output as map for `|\u003e Iteraptor.to_flatmap |\u003e Iteraptor.from_flatmap`\nback and forth transformation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fam-kantox%2Felixir-iteraptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fam-kantox%2Felixir-iteraptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fam-kantox%2Felixir-iteraptor/lists"}