completed tokenize.js port and test suite