blob: 026559b71f756245c466393285e213bebda20cab [file] [log] [blame]
avm9996337601bc2022-02-21 10:36:45 +01001// 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).
4export 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}