@li0ard/tinytlv
Version:
Tiny TLV decoder and encoder
55 lines (54 loc) • 1.38 kB
TypeScript
/** TLV class */
export declare class TLV {
/** Tag (as hex) */
tag: string;
/** Length */
length: number;
/** Value (as hex) */
value: string;
/** Value (as Uint8Array) */
byteValue: Uint8Array;
/** Childs */
childs: TLV[];
/** Parent object */
parent: TLV | null;
/** Is constructed or primitive? */
isConstructed: boolean;
/** Combined length of tag, length and value field */
size: number;
/**
* Initialize TLV object
* @param tag Tag
* @param value Value
* @example new TLV('84', '325041592E5359532E4444463031');
*/
constructor(tag: string | number, value: string | Uint8Array);
/**
* Encode TLV as string
* @returns {string}
*/
toString(): string;
/**
* Encode TLV as Uint8Array
* @returns {Uint8Array}
*/
toBytes(): Uint8Array;
/**
* Find `tag` in childs of main object
* @param tag Tag to find
* @returns {TLV | undefined}
*/
find(tag: string | number): TLV | undefined;
/**
* Find all `tag`'s in childs of main object
* @param tag Tag to find
* @returns {TLV[]}
*/
findAll(tag: string | number): TLV[];
/**
* Parse TLV from string or Uint8Array
* @param data Data to parse
* @returns {TLV}
*/
static parse(data: string | Uint8Array): TLV;
}