function wrapStr(text, width, opt_indent) {
  var out = [],
      indent = opt_indent || '';

  if (indent.length >= width) {
    throw Error('Wrapped line indentation is longer than permitted width: ' +
        indent.length + ' >= ' + width);
  }

  text.split('\n').forEach(function(line) {
    if (/^\s*$/.test(line)) {
      out.push('');  // Push a blank line.
      return;
    }

    do {
      line = indent + trimStr(line);
      out.push(line.substring(0, width));
      line = line.substring(width);
    } while (line);
  });

  return out;
}
function wrapStr(text, width, opt_indent) {
  var out = [],
      indent = opt_indent || '';

  if (indent.length >= width) {
    throw Error('Wrapped line indentation is longer than permitted width: ' +
        indent.length + ' >= ' + width);
  }

  text.split('\n').forEach(function(line) {
    if (/^\s*$/.test(line)) {
      out.push('');  // Push a blank line.
      return;
    }

    do {
      line = indent + trimStr(line);
      out.push(line.substring(0, width));
      line = line.substring(width);
    } while (line);
  });

  return out;
}
function wrapStr ( text , width , opt_indent ) { var out = [ ] , indent = opt_indent || '' ; if ( indent . length >= width ) { throw Error ( 'Wrapped line indentation is longer than permitted width: ' + indent . length + ' >= ' + width ) ; } text . split ( '\n' ) . forEach ( function ( line ) { if ( / ^\s*$ / . test ( line ) ) { out . push ( '' ) ; // Push a blank line. return ; } do { line = indent + trimStr ( line ) ; out . push ( line . substring ( 0 , width ) ) ; line = line . substring ( width ) ; } while ( line ) ; } ) ; return out ; }
Wraps the provided {@code text} so every line is at most {@code width}
characters long.
@param {string} text The text to wrap.
@param {number} width The maximum line length.
@param {string=} opt_indent String that will be prepended to each line.
Defaults to the empty string.
@return {!Array.<string>} A list of lines, without newline characters.
Wraps the provided {
Wrap a string with spaces