DEV Community

Calin Baenen
Calin Baenen

Posted on

ParseJS update: Tokens are now sorted by length and dictionary order.

A new commit was made to the ParseJS repository, it contains an update that will prevent smaller tokens from potentially wrongfully being placed.

This is the bug in question:

parse_string("Hello, world!", ["Hell", "Hello"]);
// Produces: [Symbol(Hell), 'o', ',', ' ', 'w', ...]

// But, this--
parse_string("Hello, world!", ["Hello", "Hell"]);
// -- produces: [Symbol(Hello), ',', ' ', 'w', 'o', 'r', ...]
Enter fullscreen mode Exit fullscreen mode

Now, in this update, the order won't matter, the longer token is always chosen if it can be.

Top comments (0)