UNPKG

@aokiapp/tlv

Version:

Tag-Length-Value (TLV) parser and builder library with schema support. Provides both parsing and building APIs as submodules.

51 lines 2.08 kB
import { TLVResult, TagClass } from "../common/types.js"; export declare class BasicTLVParser { /** * Parse a buffer containing a single TLV structure. * @param buffer - The TLV data buffer to parse. * @returns The parsed result including tag, length, and value. */ static parse(buffer: ArrayBuffer): TLVResult; /** * Read the tag portion from the DataView and update the offset. * @param view - The DataView representing the TLV buffer. * @param offset - The current read position within the buffer. * @returns An object containing the parsed tag information and the new offset. */ protected static readTagInfo(view: DataView, offset: number): { tag: { tagClass: TagClass; constructed: boolean; tagNumber: number; }; newOffset: number; }; /** * Convert tag class bits into a TagClass enum value. * @param {number} bits - The bits extracted from the tag byte. * @returns {TagClass} The corresponding TagClass. */ protected static getTagClass(bits: number): TagClass; /** * Read the length portion from the DataView and update the offset. * @param view - The DataView representing the TLV buffer. * @param offset - The current read position within the buffer. * @returns An object containing the parsed length and the new offset. */ protected static readLength(view: DataView, offset: number): { length: number; newOffset: number; }; /** * Read the value portion from the buffer based on the specified length. * @param buffer - The original TLV data buffer. * @param offset - The current read position within the buffer. * @param length - The length of the TLV value. * @returns An object containing the raw value slice and the new offset. */ protected static readValue(buffer: ArrayBuffer, offset: number, length: number): { value: ArrayBuffer; newOffset: number; }; } //# sourceMappingURL=basic-parser.d.ts.map