UNPKG

@vitruvius-labs/ts-predicate

Version:
16 lines (15 loc) 448 B
function getName(value) { if (typeof value === "function") { return value.name; } if (typeof value === "object" && value !== null) { // eslint-disable-next-line @ts/no-unsafe-assignment -- Prototype is loosely typed const PROTO = Object.getPrototypeOf(value); if (PROTO === null) { return ""; } return PROTO.constructor.name; } return undefined; } export { getName };