Truncate 'string'
@param {String} string
@returns {String}
426670
function truncate(string) {
  if (string.length > SEG_LENGTH * 2 + 3) {
    return string.slice(0, SEG_LENGTH) + '...' + string.slice(-SEG_LENGTH);
  }

  return string;
}
519491
function formatString (string) {
    const separator = "\n";
    return Array.isArray(string) ?
        string.reduce((acc, line) => acc.concat(line.split(separator)), []) :
        string.split(separator);
}
863558
def truncate(s: str, length: int = DEFAULT_CURTAIL) -> str:
    
    if len(s) > length:
        s = s[: length - 1] + '…'
    return s
932948
func TruncateString(str string, limit int) string {
	if len(str) < limit {
		return str
	}
	return str[:limit]
}
233623
public static String truncate(String string, int maxBytesLength) {
        byte[] stringBytes = string.getBytes();
        return stringBytes.length > maxBytesLength
                ? new String(stringBytes, 0, maxBytesLength - 1) : string;
    }
978963
function truncate(input, length, suffix, preserve) {

  length = isUndefined(length) ? input.length : length;
  preserve = preserve || false;
  suffix = suffix || '';

  if(!isString(input) || (input.length <= length)) return input;

  return input.substring(0, (preserve) ?
    ((input.indexOf(' ', length) === -1) ? input.length : input.indexOf(' ', length)) :
    length) + suffix;
}
614170
public static String truncate(String str, int count)
    {
        if(count < 0 || str.length() <= count)
            return str;

        int pos = count;
        for(int i = count; i >= 0 && !Character.isWhitespace(str.charAt(i)); i--, pos--);
        return str.substring(0, pos)+"...";
    }
1074914
private String truncateAt(final String input, final String searchString) {
        final int i = input.indexOf(searchString);
        if (i != -1) {
            return input.substring(0, i);
        }
        return input;
    }
27510
public static function truncate( $string , $at ) {

        if ( strlen( $string ) <= $at ) return $string;

        return substr( $string , 0 , $at ) . '...';

    }
150361
public function truncate($length, $substring = '') {
		if ($this->length() <= $length) {
			return new Text($this->string, $this->encoding);
		}

		$substrLen = mb_strlen($substring, $this->encoding);

		if ($this->length() + $substrLen > $length) {
			$length -= $substrLen;
		}

		return $this->substring(0, $length)->append($substring);
	}
299383
def truncate_default(str)
      return str unless str.kind_of? String
      str.sub!(/^'(.*)'$/m,'\1')
      str = "#{str[0..10]}..." if str.size > 10
      str.inspect
    end
511142
function endsWith(longStr, shortStr) {
		var longLen = longStr.length, shortLen = shortStr.length;
		return (longLen >= shortLen) &&
			(longStr.substr(longLen - shortLen) === shortStr);
	}
1006608
public static function truncate($string, int $length=16) {
		// if string is longer than authorized truncate, else do nothing
		return(
			strlen($string) > $length ? 
			trim(mb_substr(strip_tags($string), 0, $length - 2, Response::getCharset())).'…' : 
			$string
		);
	}
669894
function stringPadEnd (str, targetLength, padString, UNDEFINED) {
  var rest = '' + str
  targetLength = targetLength >> 0
  padString = padString === UNDEFINED ? ' ' : '' + padString
  if (rest.padEnd) {
    return rest.padEnd(targetLength, padString)
  }
  if (targetLength > rest.length) {
    targetLength -= rest.length
    if (targetLength > padString.length) {
      padString += stringRepeat(padString, targetLength / padString.length)
    }
    return rest + padString.slice(0, targetLength)
  }
  return rest
}
9159
function(string) {
			return string.replace(/[A-Z]/g, function(all, letter) {
				return "-" + string.charAt(letter).toLowerCase();
			});
		}
279204
public static function truncate($str, $length, $postFix = '...')
    {
        if (strlen($str) <= $length) {
            return $str;
        }

        return substr($str, 0, ($length - strlen($postFix))) . $postFix;
    }
895756
function truncateString(str, max) {

  str = str != null ? str : ''
  str = String(str)

  if(max == Infinity) return str

  var i = 0
  var wwidth = 0
  while (i < str.length) {
    var w = wcwidth(str.charAt(i))
    if(w + wwidth > max)
      break
    wwidth += w
    ++i
  }
  return str.slice(0, i)
}