Skip to content

Commit e5a82e3

Browse files
committed
Conditionally shim Number.isNaN
1 parent 5ca2494 commit e5a82e3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/util/comparisons.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const arrayFrom = require('array-from');
99

1010
const objectIs = Object.is ? Object.is : require('object-is');
1111
const objectGetOwnPropertySymbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : () => [];
12+
const numberIsNaN = Number.isNaN ? Number.isNaN : require('is-nan');
1213

1314
function uncurryThis(f) {
1415
return f.call.bind(f);
@@ -152,8 +153,8 @@ function innerDeepEqual(val1, val2, strict, memos) {
152153
// Check more closely if val1 and val2 are equal.
153154
if (strict) {
154155
if (typeof val1 !== 'object') {
155-
return typeof val1 === 'number' && Number.isNaN(val1) &&
156-
Number.isNaN(val2);
156+
return typeof val1 === 'number' && numberIsNaN(val1) &&
157+
numberIsNaN(val2);
157158
}
158159
if (typeof val2 !== 'object' || val1 === null || val2 === null) {
159160
return false;
@@ -377,7 +378,7 @@ function findLooseMatchingPrimitives(prim) {
377378
// a regular number and not NaN.
378379
// Fall through
379380
case 'number':
380-
if (Number.isNaN(prim)) {
381+
if (numberIsNaN(prim)) {
381382
return false;
382383
}
383384
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"array-from": "^2.1.1",
3434
"buffer": "^5.2.1",
3535
"es6-object-assign": "^1.1.0",
36+
"is-nan": "^1.2.1",
3637
"object-is": "^1.0.1",
3738
"util": "^0.12.0"
3839
}

0 commit comments

Comments
 (0)