function truncate(text, isLastNode) {
        var this$1 = this;

        if (!this.keepWhitespaces) {
            text = text.replace(/\s+/g, ' ');
        }
        var byWords = this.options.byWords;
        var strLen = text.length;
        var idx = 0;
        var count = 0;
        var prevIsBlank = byWords;
        var curIsBlank = false;
        while (idx < strLen) {
            curIsBlank = this$1.isBlank(text.charAt(idx++));
            // keep same then continue
            if (byWords && prevIsBlank === curIsBlank)
                { continue; }
            if (count === this$1.limit) {
                // reserve trailing whitespace
                if (curIsBlank) {
                    prevIsBlank = curIsBlank;
                    continue;
                }
                // fix idx because current char belong to next words which exceed the limit
                --idx;
                break;
            }
            if (byWords) {
                curIsBlank || ++count;
            }
            else {
                (curIsBlank && prevIsBlank) || ++count;
            }
            prevIsBlank = curIsBlank;
        }
        this.limit -= count;
        if (this.limit) {
            return text;
        }
        else {
            var str;
            if (byWords) {
                str = text.substr(0, idx);
            }
            else {
                str = this.substr(text, idx);
            }
            if (str === text) {
                // if is lat node, no need of ellipsis, or add it
                return isLastNode ? text : text + this.ellipsis;
            }
            else {
                return str + this.ellipsis;
            }
        }
    }
/**
     * truncate text
     * @param  {String}  text        text to truncate
     * @param  {Boolean} isLastNode  is last dom node, help to decide whether add ellipsis
     * @return {String}
     */
truncate text
@param  {String}  text        text to truncate
@param  {Boolean} isLastNode  is last dom node, help to decide whether add ellipsis
@return {String}
truncate text @param { String } text text to truncate @param { Boolean } isLastNode is last dom node help to decide whether add ellipsis @return { String }
function truncate(text, isLastNode) {
        var this$1 = this;
        if (!this.keepWhitespaces) {
            text = text.replace(/\s+/g, ' ');
        }
        var byWords = this.options.byWords;
        var strLen = text.length;
        var idx = 0;
        var count = 0;
        var prevIsBlank = byWords;
        var curIsBlank = false;
        while (idx < strLen) {
            curIsBlank = this$1.isBlank(text.charAt(idx++));
            if (byWords && prevIsBlank === curIsBlank)
                { continue; }
            if (count === this$1.limit) {
                if (curIsBlank) {
                    prevIsBlank = curIsBlank;
                    continue;
                }
                --idx;
                break;
            }
            if (byWords) {
                curIsBlank || ++count;
            }
            else {
                (curIsBlank && prevIsBlank) || ++count;
            }
            prevIsBlank = curIsBlank;
        }
        this.limit -= count;
        if (this.limit) {
            return text;
        }
        else {
            var str;
            if (byWords) {
                str = text.substr(0, idx);
            }
            else {
                str = this.substr(text, idx);
            }
            if (str === text) {
                return isLastNode ? text : text + this.ellipsis;
            }
            else {
                return str + this.ellipsis;
            }
        }
    }
function truncate ( text , isLastNode ) { var this$1 = this ; if ( ! this . keepWhitespaces ) { text = text . replace ( / \s+ / g , ' ' ) ; } var byWords = this . options . byWords ; var strLen = text . length ; var idx = 0 ; var count = 0 ; var prevIsBlank = byWords ; var curIsBlank = false ; while ( idx < strLen ) { curIsBlank = this$1 . isBlank ( text . charAt ( idx ++ ) ) ; if ( byWords && prevIsBlank === curIsBlank ) { continue ; } if ( count === this$1 . limit ) { if ( curIsBlank ) { prevIsBlank = curIsBlank ; continue ; } -- idx ; break ; } if ( byWords ) { curIsBlank || ++ count ; } else { ( curIsBlank && prevIsBlank ) || ++ count ; } prevIsBlank = curIsBlank ; } this . limit -= count ; if ( this . limit ) { return text ; } else { var str ; if ( byWords ) { str = text . substr ( 0 , idx ) ; } else { str = this . substr ( text , idx ) ; } if ( str === text ) { return isLastNode ? text : text + this . ellipsis ; } else { return str + this . ellipsis ; } } }
truncate text
 @param  {String}  text        text to truncate
 @param  {Boolean} isLastNode  is last dom node, help to decide whether add ellipsis
 @return {String}
truncate text @param { String } text text to truncate @param { Boolean } isLastNode is last dom node help to decide whether add ellipsis @return { String }
// keep same then continue
 // reserve trailing whitespace
 // fix idx because current char belong to next words which exceed the limit
 // if is lat node, no need of ellipsis, or add it
