UNPKG

react-refetch

Version:

A simple, declarative, and composable way to fetch data for React components.

36 lines (26 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = shallowEqual; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function shallowEqual(objA, objB) { if (objA === objB) { return true; } if (_typeof(objA) !== 'object' || _typeof(objB) !== 'object' || objA === null || objB === null) { return false; } var keysA = Object.keys(objA); var keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } // Test for A's keys different from B. var hasOwn = Object.prototype.hasOwnProperty; for (var i = 0; i < keysA.length; i++) { if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { return false; } } return true; }