(props: Record<string, any> = {})
| 12 | const emptyObjectStr = "__puck_{}"; |
| 13 | |
| 14 | function encodeEmptyObjects(props: Record<string, any> = {}) { |
| 15 | const result: Record<string, any> = {}; |
| 16 | |
| 17 | for (const key in props) { |
| 18 | if (!Object.prototype.hasOwnProperty.call(props, key)) continue; |
| 19 | |
| 20 | const val = props[key]; |
| 21 | |
| 22 | if (Array.isArray(val) && val.length === 0) { |
| 23 | result[key] = emptyArrayStr; |
| 24 | } else if (isPureObject(val) && Object.keys(val).length === 0) { |
| 25 | result[key] = emptyObjectStr; |
| 26 | } else { |
| 27 | result[key] = val; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return result; |
| 32 | } |
| 33 | |
| 34 | function decodeEmptyObjects(props: Record<string, any> = {}) { |
| 35 | const result: Record<string, any> = {}; |
no test coverage detected