arrayContainsObject.js 977 B

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