getConstructorName.js 334 B

12345678910111213141516
  1. 'use strict';
  2. /**
  3. * If `val` is an object, returns constructor name, if possible. Otherwise returns undefined.
  4. * @api private
  5. */
  6. module.exports = function getConstructorName(val) {
  7. if (val == null) {
  8. return void 0;
  9. }
  10. if (typeof val.constructor !== 'function') {
  11. return void 0;
  12. }
  13. return val.constructor.name;
  14. };