describe
tcmts.core.schema.describe · #6pejn2lk · term · runs anywhere
export function describe(v: unknown): string {
if (v === null) return "null";
if (Array.isArray(v)) return "an array";
if (v instanceof Date) return "a Date";
if (v instanceof Map) return "a Map";
if (v instanceof Set) return "a Set";
if (typeof v === "string") return `the string ${JSON.stringify(v.length > 40 ? v.slice(0, 40) + "…" : v)}`;
if (typeof v === "object") return "an object";
return `${typeof v} ${String(v)}`;
}
used by