arrayContainsObject.js 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = arrayContainsObject;
  6. var _ParseObject = _interopRequireDefault(require("./ParseObject"));
  7. function _interopRequireDefault(obj) {
  8. return obj && obj.__esModule ? obj : {
  9. default: obj
  10. };
  11. }
  12. /**
  13. * Copyright (c) 2015-present, Parse, LLC.
  14. * All rights reserved.
  15. *
  16. * This source code is licensed under the BSD-style license found in the
  17. * LICENSE file in the root directory of this source tree. An additional grant
  18. * of patent rights can be found in the PATENTS file in the same directory.
  19. *
  20. * @flow
  21. */
  22. function arrayContainsObject(array
  23. /*: Array<any>*/
  24. , object
  25. /*: ParseObject*/
  26. )
  27. /*: boolean*/
  28. {
  29. if (array.indexOf(object) > -1) {
  30. return true;
  31. }
  32. for (let i = 0; i < array.length; i++) {
  33. if (array[i] instanceof _ParseObject.default && array[i].className === object.className && array[i]._getId() === object._getId()) {
  34. return true;
  35. }
  36. }
  37. return false;
  38. }