bootstrap-styled
Version:
Bootstrap Styled is a front-end ecosystem for React made with Bootstrap 4 philosophy, using the power of css-in-js thanks to styled-components.
33 lines (27 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getFunctionName = getFunctionName;
exports.default = void 0;
// https://raw.githubusercontent.com/mui-org/material-ui/83adb95e594d7799b5f399a824f0d72f749ba349/packages/material-ui-utils/src/getDisplayName.test.js
// Fork of recompose/getDisplayName with added IE 11 support
// Simplified polyfill for IE 11 support
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3
var fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;
function getFunctionName(fn) {
var match = "".concat(fn).match(fnNameMatchRegex);
var name = match && match[1];
return name || '';
}
function getDisplayName(Component) {
if (typeof Component === 'string') {
return Component;
}
if (!Component) {
return undefined;
}
return Component.displayName || Component.name || getFunctionName(Component) || 'Component';
}
var _default = getDisplayName;
exports.default = _default;