class-name.js 752 B

12345678910111213141516171819
  1. "use strict";
  2. var functionName = require("./function-name");
  3. module.exports = function className(value) {
  4. return (
  5. (value.constructor && value.constructor.name) ||
  6. // The next branch is for IE11 support only:
  7. // Because the name property is not set on the prototype
  8. // of the Function object, we finally try to grab the
  9. // name from its definition. This will never be reached
  10. // in node, so we are not able to test this properly.
  11. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
  12. (typeof value.constructor === "function" &&
  13. /* istanbul ignore next */
  14. functionName(value.constructor)) ||
  15. null
  16. );
  17. };