From 09150b2bb7f75e992d42a34adf9a48149bbff74e Mon Sep 17 00:00:00 2001 From: BlackAsLight <44320105+BlackAsLight@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:47:18 +1100 Subject: [PATCH] chore: switch `+ input.byteOffset` to `, input.byteOffset` --- cbor/_common_decode.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cbor/_common_decode.ts b/cbor/_common_decode.ts index 28a60ea95d41..35929ad8288a 100644 --- a/cbor/_common_decode.ts +++ b/cbor/_common_decode.ts @@ -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]; } } @@ -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")})`,