I like it better when I can leverage open source code. Cross-pollination of ideas from other language communities can also provide interesting design ideas. I found the following that I may use, instead of writing my own parser/serializer:
- jParser – a blog post about it from its author.
- bitsyntax – Neat syntax for parsing binary data, derived from Erlang’s bit syntax. I see examples for Node.js, I wonder if it works within the browser.
If you are looking for something similar for Ruby, you can take a look at BinData. I’ll be updating this post as my work on this topic broadens. Check back.