Builds the prefix or suffix to be used when padding a string.
@private
@param {String} source
@param {String} char
@param {Number} len
@returns {String}
338434
function _getPadding (source, char, len) {
    if (!isNil(source) && type(source) !== "String") {
        source = String(source);
    }

    return _repeat(String(char)[0] || "", Math.ceil(len - source.length));
}
1095279
function pad(str) {
  if (str.length < max) {
    return str + ' '.repeat(max - str.length);
  }
  return str;
}
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)
}
1325129
function prefixMatchLength(name, prefix) {
  var prefixParts = prefix.split('/');
  var nameParts = name.split('/');
  if (prefixParts.length > nameParts.length)
    return 0;
  for (var i = 0; i < prefixParts.length; i++) {
    if (nameParts[i] != prefixParts[i])
      return 0;
  }
  return prefixParts.length;
}
1228759
public UTF8String rpad(int len, UTF8String pad) {
    int spaces = len - this.numChars(); // number of char need to pad
    if (spaces <= 0 || pad.numBytes() == 0) {
      // no padding at all, return the substring of the current string
      return substring(0, len);
    } else {
      int padChars = pad.numChars();
      int count = spaces / padChars; // how many padding string needed
      // the partial string of the padding
      UTF8String remain = pad.substring(0, spaces - padChars * count);

      byte[] data = new byte[this.numBytes + pad.numBytes * count + remain.numBytes];
      copyMemory(this.base, this.offset, data, BYTE_ARRAY_OFFSET, this.numBytes);
      int offset = this.numBytes;
      int idx = 0;
      while (idx < count) {
        copyMemory(pad.base, pad.offset, data, BYTE_ARRAY_OFFSET + offset, pad.numBytes);
        ++ idx;
        offset += pad.numBytes;
      }
      copyMemory(remain.base, remain.offset, data, BYTE_ARRAY_OFFSET + offset, remain.numBytes);

      return UTF8String.fromBytes(data);
    }
  }
900464
function removePrefix(str, prefixToken) {
  const index =  str.indexOf(prefixToken);

  if (index > -1) {
    str = str.substr(index + prefixToken.length).trim();
  }
  return str;
}
109905
public final String getFullString(final int pos, final int len, String charsetName) {
        if (pos + len > limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
                                                                             + (pos < 0 ? pos : (pos + len)));

        try {
            return new String(buffer, origin + pos, len, charsetName);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException("Unsupported encoding: " + charsetName, e);
        }
    }
615551
function endsWith(str, prefix) {
  return (str.indexOf(prefix, str.length - prefix.length) !== -1);
}
403035
function prefixLength(text, prefix) {
  const exp = new RegExp(`^${prefix.pattern}`);
  return matchLength(text, exp);
}
56950
private static int prefixLen(String o1, String o2) {
    final int l1 = o1.length(), l2 = o2.length(), l = l1 < l2 ? l1 : l2;
    int prefix = 0;
    while(prefix < l && (o1.charAt(prefix) == o2.charAt(prefix))) {
      prefix++;
    }
    return prefix;
  }
1288165
function pad (num, padLen) {
  var padding = '0000';
  num = String(num);
  return padding.substring(0, padLen - num.length) + num;
}
144432
function(fn, suffix) {
	if(suffix.charAt(0) !== '.') {
		suffix = '.' + suffix;
	}
	
	if(fn.length <= suffix.length) {
		return false;
	}
	
	var str = fn.substring(fn.length - suffix.length).toLowerCase();
	suffix = suffix.toLowerCase();
	return str === suffix;
}
182450
function CHAR(length) {
    length = length || 255;
    if (!(this instanceof CHAR)) {
        return new CHAR(length);
    }
    this.length = length;
    this.sql = 'CHAR(' + length + ')';
}
303973
def lchop(string, prefix):
    
    if string.startswith(prefix):
        return string[len(prefix):]
    return string
1221963
public static String rpad(String base, int len, String pad) {
		if (len < 0 || "".equals(pad)) {
			return null;
		} else if (len == 0) {
			return "";
		}

		char[] data = new char[len];
		char[] baseChars = base.toCharArray();
		char[] padChars = pad.toCharArray();

		int pos = 0;

		// copy the base
		while (pos < base.length() && pos < len) {
			data[pos] = baseChars[pos];
			pos += 1;
		}

		// copy the padding
		while (pos < len) {
			int i = 0;
			while (i < pad.length() && i < len - pos) {
				data[pos + i] = padChars[i];
				i += 1;
			}
			pos += pad.length();
		}

		return new String(data);
	}
98217
ColorBuffer pad(ColorBuffer str, int len) {
    int n = str.getVisibleLength();
    while (n < len) {
      str.append(" ");
      n++;
    }

    return append(str);
  }
1106950
public static boolean commonSuffixOfLength(String s, String p, int len) {
        return s != null && p != null && len >= 0 && s.regionMatches(s.length() - len, p, p.length() - len, len);
    }