tree-to-flat-map

Convert a tree to a flat map with dot-separated keys

Usage no npm install needed!

<script type="module">
  import treeToFlatMap from 'https://cdn.skypack.dev/tree-to-flat-map';
</script>

README

tree-to-flat-map converts a tree to a flat map with dot-separated keys.

import { treeToFlatMap } from "tree-to-flat-map";

console.log(
  treeToFlatMap(
    {
      a: {
        b: {
          c: true,
        },
      },
      d: {
        e: 1,
      },
      f: "leaf",
    },
    { separator: "." }
  )
);
// {"a.b.c": true, "d.e": 1, "f": "leaf"}