|
|
@ -64,15 +64,15 @@ export class AstWalker extends EventEmitter { |
|
|
|
nodes = nodes.filter(e => e) |
|
|
|
nodes = nodes.filter(e => e) |
|
|
|
|
|
|
|
|
|
|
|
// If any element in nodes is array, extract its members
|
|
|
|
// If any element in nodes is array, extract its members
|
|
|
|
let objNodes = [] |
|
|
|
const objNodes = [] |
|
|
|
nodes.forEach(x => {
|
|
|
|
nodes.forEach(x => {
|
|
|
|
if (Array.isArray(x)) objNodes.push(...x) |
|
|
|
if (Array.isArray(x)) objNodes.push(...x) |
|
|
|
else objNodes.push(x) |
|
|
|
else objNodes.push(x) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Filter duplicate nodes using id field
|
|
|
|
// Filter duplicate nodes using id field
|
|
|
|
let normalizedNodes = [] |
|
|
|
const normalizedNodes = [] |
|
|
|
objNodes.forEach((element, index) => { |
|
|
|
objNodes.forEach((element) => { |
|
|
|
const firstIndex = normalizedNodes.findIndex(e => e.id === element.id) |
|
|
|
const firstIndex = normalizedNodes.findIndex(e => e.id === element.id) |
|
|
|
if(firstIndex == -1) normalizedNodes.push(element) |
|
|
|
if(firstIndex == -1) normalizedNodes.push(element) |
|
|
|
}) |
|
|
|
}) |
|
|
|