function substr(str, len) {
        // var boundary, cutted, result
        var cutted = str.substr(0, len);
        if (!this.reserveLastWord) {
            return cutted;
        }
        var boundary = str.substring(len - 1, len + 1);
        // if truncate at word boundary, just return
        if (/\W/.test(boundary)) {
            return cutted;
        }
        if (this.reserveLastWord < 0) {
            var result = cutted.replace(/\w+$/, '');
            // if the cutted is not the first and the only word
            //   then return result, or return the whole word
            if (!(result.length === 0 && cutted.length === this.options.length)) {
                return result;
            }
        }
        // set max exceeded to 10 if this.reserveLastWord is true or > 0
        var maxExceeded = this.reserveLastWord !== true && this.reserveLastWord > 0
            ? this.reserveLastWord
            : 10;
        var mtc = str.substr(len).match(/(\w+)/);
        var exceeded = mtc ? mtc[1] : '';
        return cutted + exceeded.substr(0, maxExceeded);
    }
// deal with cut string in the middle of a word

deal with cut string in the middle of a word
deal with cut string in the middle of a word
function substr(str, len) {
        var cutted = str.substr(0, len);
        if (!this.reserveLastWord) {
            return cutted;
        }
        var boundary = str.substring(len - 1, len + 1);
        if (/\W/.test(boundary)) {
            return cutted;
        }
        if (this.reserveLastWord < 0) {
            var result = cutted.replace(/\w+$/, '');
            if (!(result.length === 0 && cutted.length === this.options.length)) {
                return result;
            }
        }
        var maxExceeded = this.reserveLastWord !== true && this.reserveLastWord > 0
            ? this.reserveLastWord
            : 10;
        var mtc = str.substr(len).match(/(\w+)/);
        var exceeded = mtc ? mtc[1] : '';
        return cutted + exceeded.substr(0, maxExceeded);
    }
function substr ( str , len ) { var cutted = str . substr ( 0 , len ) ; if ( ! this . reserveLastWord ) { return cutted ; } var boundary = str . substring ( len - 1 , len + 1 ) ; if ( / \W / . test ( boundary ) ) { return cutted ; } if ( this . reserveLastWord < 0 ) { var result = cutted . replace ( / \w+$ / , '' ) ; if ( ! ( result . length === 0 && cutted . length === this . options . length ) ) { return result ; } } var maxExceeded = this . reserveLastWord !== true && this . reserveLastWord > 0 ? this . reserveLastWord : 10 ; var mtc = str . substr ( len ) . match ( / (\w+) / ) ; var exceeded = mtc ? mtc [ 1 ] : '' ; return cutted + exceeded . substr ( 0 , maxExceeded ) ; }
deal with cut string in the middle of a word
deal with cut string in the middle of a word
// var boundary, cutted, result
 // if truncate at word boundary, just return
 // if the cutted is not the first and the only word
 //   then return result, or return the whole word
 // set max exceeded to 10 if this.reserveLastWord is true or > 0
