Skip to content

Commit

Permalink
chore: switch + input.byteOffset to , input.byteOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackAsLight committed Jan 14, 2025
1 parent 2ebfa11 commit 09150b2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cbor/_common_decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ function calcLength(
offset: number,
): [number | bigint, number] {
if (aI < 24) return [aI, offset];
const view = new DataView(input.buffer);
const view = new DataView(input.buffer, input.byteOffset, input.byteLength);
switch (aI) {
case 24:
return [view.getUint8(offset + input.byteOffset), offset + 1];
return [view.getUint8(offset), offset + 1];
case 25:
return [view.getUint16(offset + input.byteOffset), offset + 2];
return [view.getUint16(offset), offset + 2];
case 26:
return [view.getUint32(offset + input.byteOffset), offset + 4];
return [view.getUint32(offset), offset + 4];
default: // Only possible for it to be 27
return [view.getBigUint64(offset + input.byteOffset), offset + 8];
return [view.getBigUint64(offset), offset + 8];
}
}

Expand Down Expand Up @@ -312,14 +312,14 @@ function decodeSeven(
case 23:
return [undefined, offset];
}
const view = new DataView(input.buffer);
const view = new DataView(input.buffer, input.byteOffset, input.byteLength);
switch (aI) {
case 25:
return [view.getFloat16(offset + input.byteOffset), offset + 2];
return [view.getFloat16(offset), offset + 2];
case 26:
return [view.getFloat32(offset + input.byteOffset), offset + 4];
return [view.getFloat32(offset), offset + 4];
case 27:
return [view.getFloat64(offset + input.byteOffset), offset + 8];
return [view.getFloat64(offset), offset + 8];
default:
throw new RangeError(
`Cannot decode value (0b111_${aI.toString(2).padStart(5, "0")})`,
Expand Down

0 comments on commit 09150b2

Please sign in to comment.