UNPKG

@li0ard/tinytlv

Version:

Tiny TLV decoder and encoder

35 lines (34 loc) 1.04 kB
/** * Convert byte array to hex string. Uses built-in function, when available. * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' */ export declare const bytesToHex: (bytes: Uint8Array) => string; /** * Convert hex string to byte array. Uses built-in function, when available. * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) */ export declare const hexToBytes: (hex: string) => Uint8Array; /** * Convert number to hex string * @param num Number * @returns {string} */ export declare const numberToHex: (num: number) => string; /** * Adjust tag value to string * @param tag Tag * @returns {string} */ export declare const adjustTag: (tag: string | number) => string; /** * Adjust value to string * @param value Value * @returns {string} */ export declare const adjustValue: (value: string | Uint8Array) => string; /** * Get TLV length as Uint8Array * @param len Length * @returns {Uint8Array} */ export declare const getBufferLength: (len: number) => Uint8Array;