qcobjects
Version:
QCObjects is an Open-source framework that empowers full-stack developers to make micro-services and micro-frontends into an N-Tier architecture.
16 lines • 568 B
text/typescript
/**
* Returns the object or function name
*
* @param Object or function
*/
export const ObjectName = (o: any):string => {
let ret = "";
if (typeof o === "function" && Object.hasOwn(o, "name") && o.name !== "") {
ret = o.name;
} else if (typeof o !== "undefined" && typeof o.constructor === "function" && o.constructor.name !== "") {
ret = o.constructor.name;
} else if (typeof o !== "undefined" && typeof o.constructor === "object") {
ret = o.constructor.toString().replace(/\[(.*?)\]/g, "$1").split(" ").slice(1).join("");
}
return ret;
};