Browse Source

refactor(nocodb): remove jsepTreeToFormula.ts

pull/5270/head
Wing-Kam Wong 2 years ago
parent
commit
249fb55ebb
  1. 67
      packages/nocodb/src/lib/utils/common/helpers/jsepTreeToFormula.ts

67
packages/nocodb/src/lib/utils/common/helpers/jsepTreeToFormula.ts

@ -1,67 +0,0 @@
export default function jsepTreeToFormula(node) {
if (node.type === 'BinaryExpression' || node.type === 'LogicalExpression') {
return (
'(' +
jsepTreeToFormula(node.left) +
' ' +
node.operator +
' ' +
jsepTreeToFormula(node.right) +
')'
);
}
if (node.type === 'UnaryExpression') {
return node.operator + jsepTreeToFormula(node.argument);
}
if (node.type === 'MemberExpression') {
return (
jsepTreeToFormula(node.object) +
'[' +
jsepTreeToFormula(node.property) +
']'
);
}
if (node.type === 'Identifier') {
return node.name;
}
if (node.type === 'Literal') {
if (typeof node.value === 'string') {
return '"' + node.value + '"';
}
return '' + node.value;
}
if (node.type === 'CallExpression') {
return (
jsepTreeToFormula(node.callee) +
'(' +
node.arguments.map(jsepTreeToFormula).join(', ') +
')'
);
}
if (node.type === 'ArrayExpression') {
return '[' + node.elements.map(jsepTreeToFormula).join(', ') + ']';
}
if (node.type === 'Compound') {
return node.body.map((e) => jsepTreeToFormula(e)).join(' ');
}
if (node.type === 'ConditionalExpression') {
return (
jsepTreeToFormula(node.test) +
' ? ' +
jsepTreeToFormula(node.consequent) +
' : ' +
jsepTreeToFormula(node.alternate)
);
}
return '';
}
Loading…
Cancel
Save