runtypes
Version:
Runtime validation for static types
20 lines (19 loc) • 587 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const typeOf = (value) => {
const type = typeof value;
if (type === "object") {
if (value === null)
return "null";
if (Array.isArray(value))
return "array";
const prototype = globalThis.Object.getPrototypeOf(value);
if (prototype === null)
return "object";
if (prototype.constructor.name === "Object")
return "object";
return prototype.constructor.name;
}
return type;
};
exports.default = typeOf;