Skip to content

Commit

Permalink
removing array manipulations
Browse files Browse the repository at this point in the history
  • Loading branch information
Janther committed Dec 16, 2023
1 parent ac55af5 commit ad9687c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
18 changes: 5 additions & 13 deletions src/nodes/AssemblyLocalDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ import { printSeparatedList } from '../common/printer-helpers.js';
const { line } = doc.builders;

export const AssemblyLocalDefinition = {
print: ({ node, path, print }) => {
const parts = [
'let',
printSeparatedList(path.map(print, 'names'), { firstSeparator: line })
];

if (node.expression !== null) {
parts.push(':= ');
parts.push(path.call(print, 'expression'));
}

return parts;
}
print: ({ node, path, print }) => [
'let',
printSeparatedList(path.map(print, 'names'), { firstSeparator: line }),
node.expression ? [':= ', path.call(print, 'expression')] : []
]
};
26 changes: 9 additions & 17 deletions src/nodes/ExpressionStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@ const { hardline } = doc.builders;

export const ExpressionStatement = {
print: ({ node, options, path, print }) => {
const parts = [];
const comments =
path.getParentNode().type === 'IfStatement'
? printComments(node, path, options)
: [];

const parent = path.getParentNode();

if (parent.type === 'IfStatement') {
if (node.comments?.length) {
const comments = printComments(node, path, options);
if (comments?.length) {
parts.push(comments);
parts.push(hardline);
}
}
}

parts.push(path.call(print, 'expression'));
parts.push(node.omitSemicolon ? [] : ';');

return parts;
return [
comments.length ? [comments, hardline] : [],
path.call(print, 'expression'),
node.omitSemicolon ? [] : ';'
];
}
};

0 comments on commit ad9687c

Please sign in to comment.