mirror of https://github.com/nocodb/nocodb
Wing-Kam Wong
2 years ago
1 changed files with 0 additions and 67 deletions
@ -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…
Reference in new issue