utilizes.beside

Put children beside their father

Usage no npm install needed!

<script type="module">
  import utilizesBeside from 'https://cdn.skypack.dev/utilizes.beside';
</script>

README

beside

Put children beside their father

Usage: beside<T>(tree: Array<T>, prop: keyof T): Array<T>

import { beside } from 'utilizes.beside'

const tree = [
  {
    level: 0,
    id: 1,
    children: [
      {
        level: 1,
        id: 2
      }
    ]
  },
  {
    level: 0,
    id: 3,
    children: [
      {
        level: 1,
        id: 4
      }
    ]
  }
]

beside(tree, `children`)
// Output: [{ id:1, ... }, { id:2, ... }, { id:3, ... }, { id:4,... }]

This module exported from utilizes project.