LookAtMySuitBot/js/node_modules/function.name/lib/index.js

35 lines
812 B
JavaScript
Raw Normal View History

2023-12-24 20:08:39 -05:00
"use strict";
var noop6 = require("noop6");
(function () {
var NAME_FIELD = "name";
if (typeof noop6.name === "string") {
return;
}
try {
Object.defineProperty(Function.prototype, NAME_FIELD, {
get: function get() {
var nameMatch = this.toString().trim().match(/^function\s*([^\s(]+)/);
var name = nameMatch ? nameMatch[1] : "";
Object.defineProperty(this, NAME_FIELD, { value: name });
return name;
}
});
} catch (e) {}
})();
/**
* functionName
* Get the function name.
*
* @name functionName
* @function
* @param {Function} input The input function.
* @returns {String} The function name.
*/
module.exports = function functionName(input) {
return input.name;
};