lib/util/Text.js
function semanticShorten(line, maxLength) {
  var parts = line.split(/(\s|-)/g),
      part,
      shortenedParts = [],
      length = 0;

  // try to shorten via spaces + hyphens
  if (parts.length > 1) {
    while ((part = parts.shift())) {
      if (part.length + length < maxLength) {
        shortenedParts.push(part);
        length += part.length;
      } else {
        // remove previous part, too if hyphen does not fit anymore
        if (part === '-') {
          shortenedParts.pop();
        }

        break;
      }
    }
  }

  return shortenedParts.join('');
}
function semanticShorten(line, maxLength) {
  var parts = line.split(/(\s|-)/g),
      part,
      shortenedParts = [],
      length = 0;

  // try to shorten via spaces + hyphens
  if (parts.length > 1) {
    while ((part = parts.shift())) {
      if (part.length + length < maxLength) {
        shortenedParts.push(part);
        length += part.length;
      } else {
        // remove previous part, too if hyphen does not fit anymore
        if (part === '-') {
          shortenedParts.pop();
        }

        break;
      }
    }
  }

  return shortenedParts.join('');
}
function semanticShorten ( line , maxLength ) { var parts = line . split ( / (\s|-) / g ) , part , shortenedParts = [ ] , length = 0 ; // try to shorten via spaces + hyphens if ( parts . length > 1 ) { while ( ( part = parts . shift ( ) ) ) { if ( part . length + length < maxLength ) { shortenedParts . push ( part ) ; length += part . length ; } else { // remove previous part, too if hyphen does not fit anymore if ( part === '-' ) { shortenedParts . pop ( ) ; } break ; } } } return shortenedParts . join ( '' ) ; }
Shortens a line based on spacing and hyphens.
Returns the shortened result on success.

@param  {String} line
@param  {Number} maxLength the maximum characters of the string
@return {String} the shortened string
Shortens a line based on spacing and hyphens . Returns the shortened result on success .