mirror of
https://github.com/HoshinoSuzumi/rayine-ui.git
synced 2025-04-07 11:38:50 +08:00
18 lines
370 B
TypeScript
18 lines
370 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
|
|
}
|