MCPcopy Create free account
hub / github.com/codemix/graph / flattenOnce

Function flattenOnce

packages/graph/src/test/debug-edges.test.ts:61–71  ·  view source on GitHub ↗
(arr: any[])

Source from the content-addressed store, hash-verified

59
60 // Flatten if needed - items could be edges or arrays of edges
61 const flattenOnce = (arr: any[]): any[] => {
62 const flattened: any[] = [];
63 for (const item of arr) {
64 if (Array.isArray(item)) {
65 flattened.push(...item);
66 } else {
67 flattened.push(item);
68 }
69 }
70 return flattened;
71 };
72
73 const edges = flattenOnce(result);
74 expect(edges.length).toBeGreaterThan(0);

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected