diff --git a/src/thrift.ts b/src/thrift.ts index a246965..61ea46d 100644 --- a/src/thrift.ts +++ b/src/thrift.ts @@ -1,4 +1,4 @@ -import type { Decoded } from './types.ts' +import type { Decoded } from './types.d.ts' // TCompactProtocol types const CompactType = { @@ -20,14 +20,17 @@ const CompactType = { /** * Parse TCompactProtocol + * + * @param {ArrayBuffer} arrayBuffer + * @returns {Decoded>} */ -export function deserializeTCompactProtocol(buffer: ArrayBuffer): Decoded> { - const view = new DataView(buffer) +export function deserializeTCompactProtocol(arrayBuffer: ArrayBuffer): Decoded> { + const view = new DataView(arrayBuffer) let byteLength = 0 let lastFid = 0 - const value: Record = {} + const value = {} - while (byteLength < buffer.byteLength) { + while (byteLength < arrayBuffer.byteLength) { // Parse each field based on its type and add to the result object const [type, fid, newIndex, newLastFid] = readFieldBegin(view, byteLength, lastFid) byteLength = newIndex @@ -48,7 +51,11 @@ export function deserializeTCompactProtocol(buffer: ArrayBuffer): Decoded> 4 @@ -213,6 +251,9 @@ function readCollectionBegin(view: DataView, index: number): [number, number, nu /** * Convert int to varint. Outputs 1-5 bytes for int32. + * + * @param {number} n + * @returns {number[]} */ export function toVarInt(n: number): number[] { let idx = 0