insetsDiffer.js 743 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 Inset = {
  12. top: ?number,
  13. left: ?number,
  14. right: ?number,
  15. bottom: ?number,
  16. ...
  17. };
  18. const dummyInsets = {
  19. top: undefined,
  20. left: undefined,
  21. right: undefined,
  22. bottom: undefined,
  23. };
  24. const insetsDiffer = function(one: Inset, two: Inset): boolean {
  25. one = one || dummyInsets;
  26. two = two || dummyInsets;
  27. return (
  28. one !== two &&
  29. (one.top !== two.top ||
  30. one.left !== two.left ||
  31. one.right !== two.right ||
  32. one.bottom !== two.bottom)
  33. );
  34. };
  35. module.exports = insetsDiffer;