@unction/flattentree
TypeScript icon, indicating that this package has built-in type declarations

14.14.0 • Public • Published

@unction/flattenTree

Tests Stability Dependencies

string => Record<string | number | symbol, B> | Map<A, B> => Record<string | number | symbol, B> | Map<A, B>

Takes a tree and creates a single object where the root keys are conjoined nested keys.

flattenTree(
  "-"
)(
  {
    data: {
      profile: {
        name: "Kurtis Rainbolt-Greene",
        age: 24,
      },
      metadata: {
        interval: "10s",
      },
      location: "http://api.example.com/profiles/24",
    }
  }
)

Would return:

{
  "data-profile-name": "Kurtis Rainbolt-Greene",
  "data-profile-age": 24,
  "data-metadata-interval": "10s",
  "data-location": "http://api.example.com/profiles/24"
}

Readme

Keywords

Package Sidebar

Install

npm i @unction/flattentree

Weekly Downloads

1

Version

14.14.0

License

SEE LICENSE IN LICENSE

Unpacked Size

32.3 kB

Total Files

7

Last publish

Collaborators

  • krainboltgreene