propWrapper.js 726 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @fileoverview Utility functions for propWrapperFunctions setting
  3. */
  4. 'use strict';
  5. function getPropWrapperFunctions(context) {
  6. return new Set(context.settings.propWrapperFunctions || []);
  7. }
  8. function isPropWrapperFunction(context, name) {
  9. if (typeof name !== 'string') {
  10. return false;
  11. }
  12. const propWrapperFunctions = getPropWrapperFunctions(context);
  13. const splitName = name.split('.');
  14. return Array.from(propWrapperFunctions).some((func) => {
  15. if (splitName.length === 2 && func.object === splitName[0] && func.property === splitName[1]) {
  16. return true;
  17. }
  18. return name === func || func.property === name;
  19. });
  20. }
  21. module.exports = {
  22. getPropWrapperFunctions,
  23. isPropWrapperFunction
  24. };