View Source Tab (Tab v0.1.1)

Tab is a tiny library for converting Elixir terms into tabular data.

  iex> Tab.tabulate([%{a: 1, b: 2, c: 3}, %{a: 1, b: 2}])
  [
    ["a", "b", "c"],
    [1, 2, 3],
    [1, 2, nil]
  ]

Tab also works with nested data

  iex> Tab.tabulate([%{a: %{b: 1, c: 2}}])
  [
    ["a.b", "a.c"] ,
    [1, 2]
  ]

installation

Installation

If available in Hex, the package can be installed by adding tab to your list of dependencies in mix.exs:

def deps do
  [
    {:tab, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/tab.

Link to this section Summary

Functions

Collapses a nested map into a map of depth 1

Converts a list of (mostly) homogeneous Elixir terms into tabular data via the Tab.Collapsible protocol

Link to this section Functions

Link to this function

collapse_into(data, into \\ %{}, opts \\ [])

View Source

Collapses a nested map into a map of depth 1

iex> Tab.collapse_into(%{a: %{b: %{c: 1}}})
%{"a.b.c" => 1}

iex> Tab.collapse_into(%{a: %{b: %{c: 3}, c: 2}, b: 1})
%{"a.b.c" => 3, "a.c" => 2, "b" => 1}
Link to this function

tabulate(data, opts \\ [])

View Source

Converts a list of (mostly) homogeneous Elixir terms into tabular data via the Tab.Collapsible protocol

iex> Tab.tabulate([%{a: 1, b: 2, c: 3}, %{a: 4}, %{b: 5}])
[
  ["a", "b", "c"],
  [1, 2, 3],
  [4, nil, nil],
  [nil, 5, nil],
]