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.
Part of MDL-55611
Updated truncate.js to behave closer to the moodle implementation of shorten_text. Part of MDL-55611