There was some code in the charLengthAt function which was requiring that the "this" context not be null however it was unnecessary because it never uses "this" and for some reason it was being set to null after the ES6 transpiling.
Updated truncate.js to behave closer to the moodle implementation of shorten_text. Part of MDL-55611
Part of MDL-55611