aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fbjs/lib/shallowEqual.js.flow
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/fbjs/lib/shallowEqual.js.flow')
-rw-r--r--node_modules/fbjs/lib/shallowEqual.js.flow66
1 files changed, 0 insertions, 66 deletions
diff --git a/node_modules/fbjs/lib/shallowEqual.js.flow b/node_modules/fbjs/lib/shallowEqual.js.flow
deleted file mode 100644
index 6e72c9c9c..000000000
--- a/node_modules/fbjs/lib/shallowEqual.js.flow
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @providesModule shallowEqual
- * @typechecks
- * @flow
- */
-
-/*eslint-disable no-self-compare */
-
-'use strict';
-
-const hasOwnProperty = Object.prototype.hasOwnProperty;
-
-/**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
-function is(x: mixed, y: mixed): boolean {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- // Added the nonzero y check to make Flow happy, but it is redundant
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
- }
-}
-
-/**
- * Performs equality by iterating through keys on an object and returning false
- * when any key has values which are not strictly equal between the arguments.
- * Returns true when the values of all keys are strictly equal.
- */
-function shallowEqual(objA: mixed, objB: mixed): boolean {
- if (is(objA, objB)) {
- return true;
- }
-
- if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
- return false;
- }
-
- const keysA = Object.keys(objA);
- const keysB = Object.keys(objB);
-
- if (keysA.length !== keysB.length) {
- return false;
- }
-
- // Test for A's keys different from B.
- for (let i = 0; i < keysA.length; i++) {
- if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
- return false;
- }
- }
-
- return true;
-}
-
-module.exports = shallowEqual; \ No newline at end of file