(ast)
| 458 | * @returns {object[]} A new AST array with duplicate-named defs removed (first wins). |
| 459 | */ |
| 460 | export function dedupeDefs(ast) { |
| 461 | const seen = new Set() |
| 462 | const out = [] |
| 463 | for (const def of ast) { |
| 464 | if (def && typeof def === 'object' && typeof def.Name === 'string') { |
| 465 | if (seen.has(def.Name)) continue |
| 466 | seen.add(def.Name) |
| 467 | } |
| 468 | out.push(def) |
| 469 | } |
| 470 | return out |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Apply all normalizations to a raw BiDi AST. Pure — does not mutate `ast`. |
no test coverage detected