String.prototype.padEnd

@param {string} string string
@param {number} targetLength padding length
@returns {string} string
17643
function padEnd (string, targetLength) {
  if (typeof string !== 'string' ||
    typeof targetLength !== 'number') {
    return string
  }

  /* istanbul ignore next */
  const fn = typeof String.prototype.padEnd === 'function'
    ? String.prototype.padEnd
    : polyfill

  return fn.call(string, targetLength)
}
657637
function(string, maxLength) {
            if (!string) return string;
            if (maxLength < 1) return string;
            if (string.length <= maxLength) return string;
            if (maxLength == 1) return string.substring(0,1) + '...';

            var midpoint = Math.ceil(string.length / 2);
            var toremove = string.length - maxLength;
            var lstrip = Math.ceil(toremove/2);
            var rstrip = toremove - lstrip;
            return string.substring(0, midpoint-lstrip) + '...' + string.substring(midpoint+rstrip);
        }
969313
function pad(text, length, align = 'left') {
  let pad = ' '.repeat(length - stringWidth(text));
  if (align === 'right') {
    return pad + text;
  }

  return text + pad;
}
441327
function pad (content, length) {
    content = content || ''

    while (content.length < length) {
      content = content + ' '
    }

    return content
  }
894757
public static function str_pad($str, int $pad_length, $pad_string=' ', int $pad_type=\STR_PAD_RIGHT) {
		ref\mb::str_pad($str, $pad_length, $pad_string, $pad_type);
		return $str;
	}
134241
function pad(val, len) {
        val = val.toString();
        var padded = [];

        for (var i = 0, j = Math.max(len - val.length, 0); i < j; i++) {
            padded.push('0');
        }

        padded.push(val);
        return padded.join('');
    }
521706
public function pad($input, $padLength, $padString, $padType = STR_PAD_RIGHT) {
		$length = mb_strlen($input);
		if ($padLength - $length > 0) {
			switch ($padType) {
				case STR_PAD_LEFT:
					$input = str_repeat($padString, $padLength - $length) . $input;
					break;
				case STR_PAD_RIGHT:
					$input .= str_repeat($padString, $padLength - $length);
					break;
			}
		}
		return $input;
	}
376965
public static function padRight(string $string, int $length, string $filler = ' '): string
    {
        while (self::length($string) <= ($length - self::length($filler))) {
            $string = $string . $filler;
        }
        return $string;
    }
838845
function(value, maxLen, padChar) {
        value = value || '';
        return value + _getPadString(value, maxLen, padChar);
    }
688007
function padded_string(str)
{
   if (str.length == 0)
       return '';
 
   var pad = padded_length(str.length) - str.length;
   var res = str;
   for (var i=0; i < pad; ++i)
       res += String.fromCharCode(0);

   return res;
}
342373
public static String fixLength(final String text, final int charsNum, final char paddingChar)
    {
        return fixLength(text, charsNum, paddingChar, false);
    }
314683
function padRight(x, padding) {
  if (x) {
    x += '';
  } else {
    x = '';
  }
  var buf = [];
  while (buf.length + x.length < padding) {
    buf.push('0');
  }
  return x + buf.join('');
}
1129777
public function stringPad($input, $pad_length, $pad_string = ' ')
    {
        $count = strlen($input);

        // Fix μ issues
        if(strpos($input, 'μ'))
            $count--;

        $space = $pad_length - $count;

        return str_repeat($pad_string, $space) . $input;
    }
1028778
function padding(size,ch){
    var str = '';
    if(!ch && ch !== 0){
        ch = ' ';
    }
    while(size !== 0){
        if(size & 1 === 1){
            str += ch;
        }
        ch += ch;
        size >>>= 1;
    }
    return str;
}
1153885
function padz(str, len) {
    if (len === void 0) { len = 2; }
    return (new Array(len).join('0') + str).slice(-len);
}
1095780
async function getPkcs1Padding(length) {
  let result = '';
  while (result.length < length) {
    const randomBytes = await random.getRandomBytes(length - result.length);
    for (let i = 0; i < randomBytes.length; i++) {
      if (randomBytes[i] !== 0) {
        result += String.fromCharCode(randomBytes[i]);
      }
    }
  }
  return result;
}
1121089
private static function createPointerString(string $string, int $padding): string
    {
        $pointer = str_repeat(" ", $padding) . "^";

        return $string . "\n" . $pointer;
    }