ChatGPT-Next-Web/app/utils/format.ts

11 lines
240 B
TypeScript
Raw Normal View History

export function prettyObject(msg: any) {
2023-05-24 13:08:32 +00:00
const obj = msg;
2023-05-20 11:58:12 +00:00
if (typeof msg !== "string") {
msg = JSON.stringify(msg, null, " ");
}
2023-05-24 13:08:32 +00:00
if (msg === "{}") {
return obj.toString();
}
return ["```json", msg, "```"].join("\n");
}