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.
 
 
 
 

32 lines
889 B

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getFunctionName = getFunctionName;
  6. exports.default = void 0;
  7. // Fork of recompose/getDisplayName with added IE 11 support
  8. // Simplified polyfill for IE 11 support
  9. // https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
  10. var fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
  11. function getFunctionName(fn) {
  12. var match = "".concat(fn).match(fnNameMatchRegex);
  13. var name = match && match[1];
  14. return name || '';
  15. }
  16. function getDisplayName(Component) {
  17. if (typeof Component === 'string') {
  18. return Component;
  19. }
  20. if (!Component) {
  21. return undefined;
  22. }
  23. return Component.displayName || Component.name || getFunctionName(Component) || 'Component';
  24. }
  25. var _default = getDisplayName;
  26. exports.default = _default;