您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

_getFuncName.js 756B

12345678910111213141516171819202122232425262728293031
  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;