Created
February 17, 2021 06:47
-
-
Save vladanyes/6dc31461114a8280a6be77b0609c783c to your computer and use it in GitHub Desktop.
react-comparison-algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) Facebook, Inc. and its affiliates. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE file in the root directory of this source tree. | |
* | |
* @flow | |
*/ | |
/** | |
* 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: any, y: any) { | |
return ( | |
(x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare | |
); | |
} | |
const objectIs: (x: any, y: any) => boolean = | |
typeof Object.is === 'function' ? Object.is : is; | |
export default objectIs; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment