contexD / tree-to-flat-map

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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"}

About

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

License:MIT License


Languages

Language:TypeScript 100.0%