pointsDiffer.js 549 B

123456789101112131415161718192021222324252627
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow
  9. */
  10. 'use strict';
  11. type Point = {
  12. x: ?number,
  13. y: ?number,
  14. ...
  15. };
  16. const dummyPoint = {x: undefined, y: undefined};
  17. const pointsDiffer = function(one: ?Point, two: ?Point): boolean {
  18. one = one || dummyPoint;
  19. two = two || dummyPoint;
  20. return one !== two && (one.x !== two.x || one.y !== two.y);
  21. };
  22. module.exports = pointsDiffer;