From aafaa74d9ab239a52404907a710acebcd6ba5745 Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Wed, 24 Sep 2025 17:18:34 -0500 Subject: [PATCH] Replace isNaN with Number.isNaN in jsexecute --- src/compiler/jsexecute.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/jsexecute.js b/src/compiler/jsexecute.js index e8139245512..1f7847a3794 100644 --- a/src/compiler/jsexecute.js +++ b/src/compiler/jsexecute.js @@ -278,12 +278,12 @@ baseRuntime += `const isNotActuallyZero = val => { */ baseRuntime += `const compareEqualSlow = (v1, v2) => { const n1 = +v1; - if (isNaN(n1) || (n1 === 0 && isNotActuallyZero(v1))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase(); + if (Number.isNaN(n1) || (n1 === 0 && isNotActuallyZero(v1))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase(); const n2 = +v2; - if (isNaN(n2) || (n2 === 0 && isNotActuallyZero(v2))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase(); + if (Number.isNaN(n2) || (n2 === 0 && isNotActuallyZero(v2))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase(); return n1 === n2; }; -const compareEqual = (v1, v2) => (typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) && !isNaN(v2) || v1 === v2) ? v1 === v2 : compareEqualSlow(v1, v2);`; +const compareEqual = (v1, v2) => (typeof v1 === 'number' && typeof v2 === 'number' && !Number.isNaN(v1) && !Number.isNaN(v2) || v1 === v2) ? v1 === v2 : compareEqualSlow(v1, v2);`; /** * Determine if one value is greater than another. @@ -299,14 +299,14 @@ runtimeFunctions.compareGreaterThan = `const compareGreaterThanSlow = (v1, v2) = } else if (n2 === 0 && isNotActuallyZero(v2)) { n2 = NaN; } - if (isNaN(n1) || isNaN(n2)) { + if (Number.isNaN(n1) || Number.isNaN(n2)) { const s1 = ('' + v1).toLowerCase(); const s2 = ('' + v2).toLowerCase(); return s1 > s2; } return n1 > n2; }; -const compareGreaterThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) ? v1 > v2 : compareGreaterThanSlow(v1, v2)`; +const compareGreaterThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !Number.isNaN(v1) ? v1 > v2 : compareGreaterThanSlow(v1, v2)`; /** * Determine if one value is less than another. @@ -322,14 +322,14 @@ runtimeFunctions.compareLessThan = `const compareLessThanSlow = (v1, v2) => { } else if (n2 === 0 && isNotActuallyZero(v2)) { n2 = NaN; } - if (isNaN(n1) || isNaN(n2)) { + if (Number.isNaN(n1) || Number.isNaN(n2)) { const s1 = ('' + v1).toLowerCase(); const s2 = ('' + v2).toLowerCase(); return s1 < s2; } return n1 < n2; }; -const compareLessThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v2) ? v1 < v2 : compareLessThanSlow(v1, v2)`; +const compareLessThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !Number.isNaN(v2) ? v1 < v2 : compareLessThanSlow(v1, v2)`; /** * Generate a random integer.