Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type StackArrayState = {
type: State.ARRAY;
size: number;
array: Array<unknown>;
position: number;
};

type StackState = StackArrayState | StackMapState;
Expand Down Expand Up @@ -318,8 +319,9 @@ export class Decoder {
// arrays and maps
const state = stack[stack.length - 1];
if (state.type === State.ARRAY) {
state.array.push(object);
if (state.array.length === state.size) {
state.array[state.position] = object;
state.position++;
if (state.position === state.size) {
stack.pop();
object = state.array;
} else {
Expand Down Expand Up @@ -387,7 +389,8 @@ export class Decoder {
this.stack.push({
type: State.ARRAY,
size,
array: [],
array: new Array<unknown>(size),
position: 0,
});
}

Expand Down