UNPKG

mocoolka-function

Version:

Function lib for function.

19 lines 647 B
/** * Gets the name of a function, in a cross-browser way. * * @param {Function} fn function (usually a constructor) * @return {string} */ Object.defineProperty(exports, "__esModule", { value: true }); var name = function (fn) { var functionName = fn['displayName'] == null ? fn['name'] : fn['displayName']; if (!functionName) { /* istanbul ignore next */ var match = /^\s?function ([^(]*)\(/.exec(fn.toString()); /* istanbul ignore next */ functionName = match && match[1] ? match[1] : ''; } return functionName; }; exports.default = name; //# sourceMappingURL=getName.js.map