apollo-utilities
Advanced tools
Comparing version 0.2.0-alpha.6 to 0.2.0-beta.0
@@ -7,2 +7,5 @@ "use strict"; | ||
} | ||
if (a instanceof Date && b instanceof Date) { | ||
return a.getTime() === b.getTime(); | ||
} | ||
if (a != null && | ||
@@ -13,4 +16,4 @@ typeof a === 'object' && | ||
for (var key in a) { | ||
if (a.hasOwnProperty(key)) { | ||
if (!b.hasOwnProperty(key)) { | ||
if (Object.prototype.hasOwnProperty.call(a, key)) { | ||
if (!Object.prototype.hasOwnProperty.call(b, key)) { | ||
return false; | ||
@@ -24,3 +27,3 @@ } | ||
for (var key in b) { | ||
if (!a.hasOwnProperty(key)) { | ||
if (!Object.prototype.hasOwnProperty.call(a, key)) { | ||
return false; | ||
@@ -27,0 +30,0 @@ } |
{ | ||
"name": "apollo-utilities", | ||
"version": "0.2.0-alpha.6", | ||
"version": "0.2.0-beta.0", | ||
"description": "Utilities for working with GraphQL ASTs", | ||
@@ -5,0 +5,0 @@ "author": "James Baxley <james@meteor.com>", |
@@ -65,2 +65,23 @@ import { isEqual } from '../isEqual'; | ||
}); | ||
it('should correctly compare deep objects without object prototype ', () => { | ||
// Solves https://github.com/apollographql/apollo-client/issues/2132 | ||
const objNoProto = Object.create(null); | ||
objNoProto.a = { b: 2, c: [3, 4] }; | ||
objNoProto.e = Object.create(null); | ||
objNoProto.e.f = 5; | ||
expect(isEqual(objNoProto, { a: { b: 2, c: [3, 4] }, e: { f: 5 } })).toBe( | ||
true, | ||
); | ||
expect(!isEqual(objNoProto, { a: { b: 2, c: [3, 4] }, e: { f: 6 } })).toBe( | ||
true, | ||
); | ||
expect(!isEqual(objNoProto, { a: { b: 2, c: [3, 4] }, e: null })).toBe( | ||
true, | ||
); | ||
expect(!isEqual(objNoProto, { a: { b: 2, c: [3] }, e: { f: 5 } })).toBe( | ||
true, | ||
); | ||
expect(!isEqual(objNoProto, null)).toBe(true); | ||
}); | ||
}); |
@@ -9,2 +9,6 @@ /** | ||
} | ||
// Dates are equivalent if their time values are equal. | ||
if (a instanceof Date && b instanceof Date) { | ||
return a.getTime() === b.getTime(); | ||
} | ||
// If a and b are both objects, we will compare their properties. This will compare arrays as | ||
@@ -21,4 +25,4 @@ // well. | ||
for (const key in a) { | ||
if (a.hasOwnProperty(key)) { | ||
if (!b.hasOwnProperty(key)) { | ||
if (Object.prototype.hasOwnProperty.call(a, key)) { | ||
if (!Object.prototype.hasOwnProperty.call(b, key)) { | ||
return false; | ||
@@ -33,3 +37,3 @@ } | ||
for (const key in b) { | ||
if (!a.hasOwnProperty(key)) { | ||
if (!Object.prototype.hasOwnProperty.call(a, key)) { | ||
return false; | ||
@@ -36,0 +40,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137289
3459