Skip to content

Commit

Permalink
chore: cleanup depth debug code and assert found key in test
Browse files Browse the repository at this point in the history
  • Loading branch information
sod committed Nov 24, 2023
1 parent 3008b15 commit 2d91022
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/parsers/pipe.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ export const TRANSLATE_PIPE_NAMES = ['translate', 'marker'];
/**
* this method is meant to only cause 1 call stack per ast depth, to prevent to run into call stack limits on large templates
*/
function traverseAst<RESULT extends unknown[]>(node: any, visitor: (node: TmplAstNode) => RESULT, result: RESULT, depth = 0) {
console.log(depth);

function traverseAst<RESULT extends unknown[]>(node: any, visitor: (node: TmplAstNode) => RESULT, result: RESULT) {
if (!node) {
return;
}

if (Array.isArray(node)) {
for (const child of node) {
traverseAst(child, visitor, result, depth + 1);
traverseAst(child, visitor, result);
}
return;
}
Expand Down Expand Up @@ -62,7 +60,7 @@ function traverseAst<RESULT extends unknown[]>(node: any, visitor: (node: TmplAs
}

for (const child of children.flat()) {
traverseAst(child, visitor, result, depth + 1);
traverseAst(child, visitor, result);
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/parsers/pipe.parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ describe('PipeParser', () => {
`;

const keys = parser.extract(contents, templateFilename)?.keys();
expect(keys).to.deep.equal(['deep']);
});
});
});

0 comments on commit 2d91022

Please sign in to comment.