Break consecutive repetition of a string in Node.js and browsers.