From 681846cc931fbb02ab0d8bbc635e35fe2557a5a1 Mon Sep 17 00:00:00 2001 From: bangonicdd <157843588+bangonicdd2@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:23:52 +0900 Subject: [PATCH] fix: Add missing '!=' implementation in calcString --- src/ts/process/infunctions.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ts/process/infunctions.ts b/src/ts/process/infunctions.ts index 70f39659..8c2b508a 100644 --- a/src/ts/process/infunctions.ts +++ b/src/ts/process/infunctions.ts @@ -17,6 +17,7 @@ function toRPN(expression:string) { '≤': {precedence: 1, associativity: 'Left'}, '≥': {precedence: 1, associativity: 'Left'}, '=': {precedence: 1, associativity: 'Left'}, + '≠': {precedence: 1, associativity: 'Left'}, '!': {precedence: 5, associativity: 'Right'}, }; const operatorsKeys = Object.keys(operators); @@ -98,6 +99,7 @@ function calculateRPN(expression:string) { case '≤': stack.push(a <= b ? 1 : 0); break; case '≥': stack.push(a >= b ? 1 : 0); break; case '=': stack.push(a === b ? 1 : 0); break; + case '≠': stack.push(a !== b ? 1 : 0); break; case '!': stack.push(b ? 0 : 1); break; } } @@ -125,7 +127,14 @@ function executeRPNCalculation(text:string) { return "0" } return parsed.toString() - }).replace(/&&/g, '&').replace(/\|\|/g, '|').replace(/<=/g, '≤').replace(/>=/g, '≥').replace(/==/g, '=').replace(/null/gi, '0') + }) + .replace(/&&/g, '&') + .replace(/\|\|/g, '|') + .replace(/<=/g, '≤') + .replace(/>=/g, '≥') + .replace(/==/g, '=') + .replace(/!=/g, '≠') + .replace(/null/gi, '0') const expression = toRPN(text); const evaluated = calculateRPN(expression); return evaluated