@datadog/mobile-react-native
Version:
A client-side React Native module to interact with Datadog
36 lines (34 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.areObjectShallowEqual = void 0;
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
/**
* Does a shallow comparison between 2 objects.
*
* In some rare cases, one of the objects can be `undefined` or `null`.
* This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.
*/
const areObjectShallowEqual = (objectA, objectB) => {
// Handle edge case when one object is `undefined` or `null`
if (!objectA || !objectB) {
return objectA === objectB;
}
const keys = Object.keys(objectA);
if (keys.length !== Object.keys(objectB).length) {
return false;
}
for (const key of keys) {
if (objectA[key] !== objectB[key]) {
return false;
}
}
return true;
};
exports.areObjectShallowEqual = areObjectShallowEqual;
//# sourceMappingURL=ShallowObjectEqualityChecker.js.map