Skip to content

Commit

Permalink
Fix access of length on arrays, #57
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jan 27, 2023
1 parent 38b3eed commit b2e3901
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,8 @@ export class Encoder extends Decoder {
} else encode(value);
}
} else if (constructor === Array) {
writeArrayHeader(object.length);
let length = object.length;
writeArrayHeader(length);
for (let i = 0; i < length; i++) {
let value = object[i];
if (value && (typeof value === 'object' || position - start > chunkThreshold)) {
Expand Down

0 comments on commit b2e3901

Please sign in to comment.