Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isInclusive.js 774B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const isDefiningProjection = require('./isDefiningProjection');
  3. /*!
  4. * ignore
  5. */
  6. module.exports = function isInclusive(projection) {
  7. if (projection == null) {
  8. return false;
  9. }
  10. const props = Object.keys(projection);
  11. const numProps = props.length;
  12. if (numProps === 0) {
  13. return false;
  14. }
  15. for (let i = 0; i < numProps; ++i) {
  16. const prop = props[i];
  17. // Plus paths can't define the projection (see gh-7050)
  18. if (prop.startsWith('+')) {
  19. continue;
  20. }
  21. // If field is truthy (1, true, etc.) and not an object, then this
  22. // projection must be inclusive. If object, assume its $meta, $slice, etc.
  23. if (isDefiningProjection(projection[prop]) && !!projection[prop]) {
  24. return true;
  25. }
  26. }
  27. return false;
  28. };