ixfx
    Preparing search index...
    • Returns the direct children of a tree-like object as a pairing of node name and value. Supports basic objects, Maps and arrays.

      Sub-children are included as an object blob.

      Type Parameters

      • Textendsobject

      Parameters

      • node: T
      • options: Partial<Readonly<{ filter: "none" | "leaves" | "branches"; name: string }>> = {}

      Returns IterableIterator<Readonly<{ name: string; nodeValue: any; sourceValue: any }>>

      const o = {
      colour: {
      r: 0.5, g: 0.5, b: 0.5
      }
      };

      const children = [ ...Trees.children(o) ];
      // Children:
      // [
      // { name: "colour", value: { b: 0.5, g: 0.5, r: 0.5 } }
      // ]
      const subChildren = [ ...Trees.children(o.colour) ];
      // [ { name: "r", value: 0.5 }, { name: "g", value: 0.5 }, { name: "b", value: 0.5 } ]

      Arrays are assigned a name based on index.

      const colours = [ { r: 1, g: 0, b: 0 }, { r: 0, g: 1, b: 0 }, { r: 0, g: 0, b: 1 } ];
      // Children:
      // [
      // { name: "array[0]", value: {r:1,g:0,b:0} },
      // { name: "array[1]", value: {r:0,g:1,b:0} },
      // { name: "array[2]", value: {r:0,g:0,b:1} },
      // ]

      Pass in options.name (eg 'colours') to have names generated as 'colours[0]', etc. Options can also be used to filter children. By default all direct children are returned.