Length-Object-Binary Encoding in Javascript