/ src / components / demo / enhanced_fp / window__tree_structure.tsx
window__tree_structure.tsx
 1  import Code from "../../Code";
 2  import Output from "../../Output";
 3  
 4  const WindowTreeStructureDemo = () => {
 5    return (
 6      <div>
 7        <Code
 8          snippet={`
 9  () => {
10    let structure = "";
11  
12    try {
13      const recursiveWindow = (win = top) => {
14        const windows = [];
15  
16        for (let i = 0; i < win.length; i++)
17          windows.push(recursiveWindow(win[i]));
18  
19        return windows;
20      };
21  
22      structure = JSON.stringify(recursiveWindow());
23    } catch {}
24  
25    return structure;
26  }
27          `.trim()}
28        />
29  
30        <Output
31          generator={() => {
32            let structure = "";
33  
34            try {
35              // @ts-expect-error
36              const recursiveWindow = (win = top) => {
37                const windows = [];
38  
39                // @ts-expect-error
40                for (let i = 0; i < win.length; i++)
41                  // @ts-expect-error
42                  windows.push(recursiveWindow(win[i]));
43  
44                return windows;
45              };
46  
47              structure = JSON.stringify(recursiveWindow());
48            } catch {}
49  
50            return structure;
51          }}
52        />
53      </div>
54    );
55  };
56  
57  export default WindowTreeStructureDemo;