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.

31 lines
756 B

  1. var realNames = require('./_realNames');
  2. /** Used for built-in method references. */
  3. var objectProto = Object.prototype;
  4. /** Used to check objects for own properties. */
  5. var hasOwnProperty = objectProto.hasOwnProperty;
  6. /**
  7. * Gets the name of `func`.
  8. *
  9. * @private
  10. * @param {Function} func The function to query.
  11. * @returns {string} Returns the function name.
  12. */
  13. function getFuncName(func) {
  14. var result = (func.name + ''),
  15. array = realNames[result],
  16. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  17. while (length--) {
  18. var data = array[length],
  19. otherFunc = data.func;
  20. if (otherFunc == null || otherFunc == func) {
  21. return data.name;
  22. }
  23. }
  24. return result;
  25. }
  26. module.exports = getFuncName;