Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
80ac4d0b
Commit
80ac4d0b
authored
Oct 02, 2020
by
aniket-engg
Committed by
Aniket
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node normalized
parent
e555d646
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
astWalker.ts
libs/remix-astwalker/src/astWalker.ts
+18
-6
No files found.
libs/remix-astwalker/src/astWalker.ts
View file @
80ac4d0b
...
...
@@ -60,11 +60,23 @@ export class AstWalker extends EventEmitter {
}
normalizeNodes
(
nodes
:
AstNode
[]):
AstNode
[]
{
// TODO: Traverse through nodes to check:
// 1. If value exists for element
// 2. If any element in nodes is array, extract its members in nodes and delete it
// 3. duplicate nodes using id field
return
nodes
// Remove null, undefined and empty elements if any
nodes
=
nodes
.
filter
(
e
=>
e
)
// If any element in nodes is array, extract its members
let
objNodes
=
[]
nodes
.
forEach
(
x
=>
{
if
(
Array
.
isArray
(
x
))
objNodes
.
push
(...
x
)
else
objNodes
.
push
(
x
)
});
// Filter duplicate nodes using id field
let
normalizedNodes
=
[]
objNodes
.
forEach
((
element
,
index
)
=>
{
const
firstIndex
=
normalizedNodes
.
findIndex
(
e
=>
e
.
id
===
element
.
id
)
if
(
firstIndex
==
-
1
)
normalizedNodes
.
push
(
element
)
})
return
normalizedNodes
}
getASTNodeChildren
(
ast
:
AstNode
):
AstNode
[]
{
...
...
@@ -140,7 +152,7 @@ export class AstWalker extends EventEmitter {
nodes
.
push
(
ast
.
endExpression
)
}
}
return
nodes
return
this
.
normalizeNodes
(
nodes
)
}
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment