avm99963 | 37601bc | 2022-02-21 10:36:45 +0100 | [diff] [blame] | 1 | // Function which converts a protobuf array into an array which can be accessed |
| 2 | // as if it was a protobuf object (with the same keys). If the input is not an |
| 3 | // array it returns itself (since it is called recursively). |
| 4 | export function correctArrayKeys(input) { |
| 5 | if (!Array.isArray(input)) return input; |
| 6 | |
| 7 | let object = []; |
| 8 | for (let i = 0; i < input.length; ++i) { |
| 9 | if (input[i] === null) continue; |
| 10 | object[i + 1] = correctArrayKeys(input[i]); |
| 11 | } |
| 12 | return object; |
| 13 | } |