diff --git a/src/api/solver.ts b/src/api/solver.ts index dbbf6d9..3ca9394 100644 --- a/src/api/solver.ts +++ b/src/api/solver.ts @@ -18,7 +18,13 @@ export default class Solver { if (equation.includes(variable) === false) return []; // Trouve les solutions de l'équation - var rawSolutions = nerdamer.solveEquations(equation + ' = ' + y, variable); + while (equation.startsWith(')')) equation = equation.slice(1); + + try { + var rawSolutions = nerdamer.solveEquations(equation + ' = ' + y, variable); + } catch { + return []; + } // Transforme les solutions en array const solutionsArray = this.stringToArray(rawSolutions.toString()); @@ -141,6 +147,8 @@ export default class Solver { if (variableValue.toString() === '0') return NaN; } + if (x === undefined) return NaN; + return this.toInteger(x.toString()); } } diff --git a/src/components/Designer.svelte b/src/components/Designer.svelte index 7967237..432d9be 100644 --- a/src/components/Designer.svelte +++ b/src/components/Designer.svelte @@ -1,8 +1,8 @@ -
+
{ - dispatch(eventName, value.trim()); + dispatch(eventName, value); }); /** @@ -91,7 +91,7 @@ {#if isEditing}