(data: Payload, prefix = '')
| 11 | } |
| 12 | |
| 13 | static flatten(data: Payload, prefix = ''): Payload { |
| 14 | let output: Payload = {}; |
| 15 | |
| 16 | for (const [key, value] of Object.entries(data)) { |
| 17 | let finalKey = prefix ? prefix + '[' + key +']' : key; |
| 18 | if (Array.isArray(value)) { |
| 19 | output = { ...output, ...Service.flatten(value, finalKey) }; |
| 20 | } else { |
| 21 | output[finalKey] = value; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | return output; |
| 26 | } |
| 27 | } |
no outgoing calls
no test coverage detected