code: function truncate(text, isLastNode) {
          var this$1 = this;
  
          if (!this.keepWhitespaces) {
              text = text.replace(/\s+/g, ' ');
          }
          var byWords = this.options.byWords;
          var match = text.match(astralRange);
          var astralSafeCharacterArray = match === null ? [] : match;
          var strLen = match === null ? 0 : astralSafeCharacterArray.length;
          var idx = 0;
          var count = 0;
          var prevIsBlank = byWords;
          var curIsBlank = false;
          while (idx < strLen) {
              curIsBlank = this$1.isBlank(astralSafeCharacterArray[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(astralSafeCharacterArray, 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;
              }
          }
      }
docs: truncate text
  @param  {String}  text        text to truncate
  @param  {Boolean} isLastNode  is last dom node, help to decide whether add ellipsis
  @return {String}