https://github.com/Automattic/mongoose
Raw File
Tip revision: fbb1f5dee897a4079516a31483a014d9ad8d9cb7 authored by Valeri Karpov on 25 October 2023, 18:15:10 UTC
chore: release 6.12.2
Tip revision: fbb1f5d
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