How to Parse TLVs in JavaScript