getConstructorName.js 318 B

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