Skip to content

Commit f794ca4

Browse files
committed
Conditionally use Object.is shim
1 parent dc0ffec commit f794ca4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

assert.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const { inspect } = require('util/');
3535
const { isPromise, isRegExp } = require('util/').types;
3636

3737
const objectAssign = Object.assign ? Object.assign : require('es6-object-assign').assign;
38+
const objectIs = Object.is ? Object.is : require('object-is');
3839

3940
const errorCache = new Map();
4041

@@ -274,7 +275,7 @@ assert.strictEqual = function strictEqual(actual, expected, message) {
274275
if (arguments.length < 2) {
275276
throw new ERR_MISSING_ARGS('actual', 'expected');
276277
}
277-
if (!Object.is(actual, expected)) {
278+
if (!objectIs(actual, expected)) {
278279
innerFail({
279280
actual,
280281
expected,
@@ -289,7 +290,7 @@ assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
289290
if (arguments.length < 2) {
290291
throw new ERR_MISSING_ARGS('actual', 'expected');
291292
}
292-
if (Object.is(actual, expected)) {
293+
if (objectIs(actual, expected)) {
293294
innerFail({
294295
actual,
295296
expected,

internal/util/comparisons.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
const regexFlagsSupported = /a/g.flags !== undefined;
77

8+
const objectIs = Object.is ? Object.is : require('object-is');
9+
810
function uncurryThis(f) {
911
return f.call.bind(f);
1012
}
@@ -98,7 +100,7 @@ function areEqualArrayBuffers(buf1, buf2) {
98100
function isEqualBoxedPrimitive(val1, val2) {
99101
if (isNumberObject(val1)) {
100102
return isNumberObject(val2) &&
101-
Object.is(Number.prototype.valueOf.call(val1),
103+
objectIs(Number.prototype.valueOf.call(val1),
102104
Number.prototype.valueOf.call(val2));
103105
}
104106
if (isStringObject(val1)) {
@@ -141,7 +143,7 @@ function innerDeepEqual(val1, val2, strict, memos) {
141143
if (val1 === val2) {
142144
if (val1 !== 0)
143145
return true;
144-
return strict ? Object.is(val1, val2) : true;
146+
return strict ? objectIs(val1, val2) : true;
145147
}
146148

147149
// Check more closely if val1 and val2 are equal.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"dependencies": {
3333
"buffer": "^5.2.1",
3434
"es6-object-assign": "^1.1.0",
35+
"object-is": "^1.0.1",
3536
"util": "^0.12.0"
3637
}
3738
}

0 commit comments

Comments
 (0)