Skip to content

Instantly share code, notes, and snippets.

@vladanyes
Created February 17, 2021 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladanyes/6dc31461114a8280a6be77b0609c783c to your computer and use it in GitHub Desktop.
Save vladanyes/6dc31461114a8280a6be77b0609c783c to your computer and use it in GitHub Desktop.
react-comparison-algorithm
/**
* 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