mirror of
https://github.com/HoshinoSuzumi/rayine-ui.git
synced 2025-04-18 07:58:51 +08:00
18 lines
375 B
TypeScript
18 lines
375 B
TypeScript
export const renderObject = (obj: any): string => {
|
|
if (Array.isArray(obj)) {
|
|
return `[${obj.map(renderObject).join(", ")}]`;
|
|
}
|
|
|
|
if (typeof obj === "object") {
|
|
return `{ ${Object.entries(obj)
|
|
.map(([key, value]) => `${key}: ${renderObject(value)}`)
|
|
.join(", ")} }`;
|
|
}
|
|
|
|
if (typeof obj === "string") {
|
|
return `'${obj}'`;
|
|
}
|
|
|
|
return obj;
|
|
};
|