https://github.com/Automattic/mongoose
Raw File
Tip revision: 09181ef655e1d0360c3b4a60f1ef15c39c56cb15 authored by Valeri Karpov on 22 January 2024, 16:03:26 UTC
chore: release 6.12.6
Tip revision: 09181ef
getConstructorName.js
'use strict';

/**
 * If `val` is an object, returns constructor name, if possible. Otherwise returns undefined.
 * @api private
 */

module.exports = function getConstructorName(val) {
  if (val == null) {
    return void 0;
  }
  if (typeof val.constructor !== 'function') {
    return void 0;
  }
  return val.constructor.name;
};
back to top