Skip to content

Commit aafaa74

Browse files
committed
Replace isNaN with Number.isNaN in jsexecute
1 parent d7a5f1c commit aafaa74

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/compiler/jsexecute.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ baseRuntime += `const isNotActuallyZero = val => {
278278
*/
279279
baseRuntime += `const compareEqualSlow = (v1, v2) => {
280280
const n1 = +v1;
281-
if (isNaN(n1) || (n1 === 0 && isNotActuallyZero(v1))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();
281+
if (Number.isNaN(n1) || (n1 === 0 && isNotActuallyZero(v1))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();
282282
const n2 = +v2;
283-
if (isNaN(n2) || (n2 === 0 && isNotActuallyZero(v2))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();
283+
if (Number.isNaN(n2) || (n2 === 0 && isNotActuallyZero(v2))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();
284284
return n1 === n2;
285285
};
286-
const compareEqual = (v1, v2) => (typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) && !isNaN(v2) || v1 === v2) ? v1 === v2 : compareEqualSlow(v1, v2);`;
286+
const compareEqual = (v1, v2) => (typeof v1 === 'number' && typeof v2 === 'number' && !Number.isNaN(v1) && !Number.isNaN(v2) || v1 === v2) ? v1 === v2 : compareEqualSlow(v1, v2);`;
287287

288288
/**
289289
* Determine if one value is greater than another.
@@ -299,14 +299,14 @@ runtimeFunctions.compareGreaterThan = `const compareGreaterThanSlow = (v1, v2) =
299299
} else if (n2 === 0 && isNotActuallyZero(v2)) {
300300
n2 = NaN;
301301
}
302-
if (isNaN(n1) || isNaN(n2)) {
302+
if (Number.isNaN(n1) || Number.isNaN(n2)) {
303303
const s1 = ('' + v1).toLowerCase();
304304
const s2 = ('' + v2).toLowerCase();
305305
return s1 > s2;
306306
}
307307
return n1 > n2;
308308
};
309-
const compareGreaterThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) ? v1 > v2 : compareGreaterThanSlow(v1, v2)`;
309+
const compareGreaterThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !Number.isNaN(v1) ? v1 > v2 : compareGreaterThanSlow(v1, v2)`;
310310

311311
/**
312312
* Determine if one value is less than another.
@@ -322,14 +322,14 @@ runtimeFunctions.compareLessThan = `const compareLessThanSlow = (v1, v2) => {
322322
} else if (n2 === 0 && isNotActuallyZero(v2)) {
323323
n2 = NaN;
324324
}
325-
if (isNaN(n1) || isNaN(n2)) {
325+
if (Number.isNaN(n1) || Number.isNaN(n2)) {
326326
const s1 = ('' + v1).toLowerCase();
327327
const s2 = ('' + v2).toLowerCase();
328328
return s1 < s2;
329329
}
330330
return n1 < n2;
331331
};
332-
const compareLessThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v2) ? v1 < v2 : compareLessThanSlow(v1, v2)`;
332+
const compareLessThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !Number.isNaN(v2) ? v1 < v2 : compareLessThanSlow(v1, v2)`;
333333

334334
/**
335335
* Generate a random integer.

0 commit comments

Comments
 (0)