UNPKG

tlv-parser

Version:

Zero-dependency recursive TLV (Tag-Length-Value) parser in pure ES modules. Supports raw TLVNode[] or nested object keyed by tag.

14 lines (13 loc) 301 B
export class TLVObjectifier { objectify(nodes) { const result = {}; for (const node of nodes) { if (node.hasChildren()) { result[node.tag] = this.objectify(node.children); } else { result[node.tag] = node.data; } } return result; } }