diff --git a/src/v1/kaitaiWorker.ts b/src/v1/kaitaiWorker.ts index 5cfec151..e198e566 100644 --- a/src/v1/kaitaiWorker.ts +++ b/src/v1/kaitaiWorker.ts @@ -83,10 +83,14 @@ function exportValue(obj: any, debug: IDebugInfo, hasRawAttr: boolean, path: str } } else if (result.type === ObjectType.Array) { - result.arrayItems = (obj).map((item, i) => exportValue(item, debug && debug.arr && debug.arr[i], hasRawAttr, path.concat(i.toString()), noLazy)); - if (result.incomplete && debug && debug.arr) { - debug.end = inferDebugEnd(debug.arr); - result.end = debug.end; + if (debug && debug.arr) { + result.arrayItems = debug.arr.map((itemDebug, i) => exportValue(obj[i], itemDebug, hasRawAttr, path.concat(i.toString()), noLazy)); + if (result.incomplete) { + debug.end = inferDebugEnd(debug.arr); + result.end = debug.end; + } + } else { + result.arrayItems = (obj).map((item, i) => exportValue(item, undefined, hasRawAttr, path.concat(i.toString()), noLazy)); } } else if (result.type === ObjectType.Object) {