isPathSelectedInclusive.js 566 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. /*!
  3. * ignore
  4. */
  5. module.exports = function isPathSelectedInclusive(fields, path) {
  6. const chunks = path.split('.');
  7. let cur = '';
  8. let j;
  9. let keys;
  10. let numKeys;
  11. for (let i = 0; i < chunks.length; ++i) {
  12. cur += cur.length ? '.' : '' + chunks[i];
  13. if (fields[cur]) {
  14. keys = Object.keys(fields);
  15. numKeys = keys.length;
  16. for (j = 0; j < numKeys; ++j) {
  17. if (keys[i].indexOf(cur + '.') === 0 && keys[i].indexOf(path) !== 0) {
  18. continue;
  19. }
  20. }
  21. return true;
  22. }
  23. }
  24. return false;
  25. };