Nodejs Utililty Methods String Padding Left

List of utility methods to do String Padding Left

Description

The list of methods to do String Padding Left are organized into topic(s).

Method

lpad(character, count)
String.prototype.lpad = function(character, count) {
    var ch = character || "0";
    var cnt = count || 2;
    var s = "";
    while (s.length < (cnt - this.length)) { s += ch; }
    s = s.substring(0, cnt-this.length);
    return s+this;
var iterate = function(collection, iterator) {
...
lpad(character, count)
String.prototype.lpad = function(character, count) {
  var ch = character || "0";
  var cnt = count || 2;
  var s = "";
  while (s.length < (cnt - this.length)) { s += ch; }
  s = s.substring(0, cnt-this.length);
  return s+this;
lpad(count, pad)
String.prototype.lpad = function(count, pad) {
  pad = pad || '0';
  str = this + '';
  return str.length >= count ? str : new Array(count - str.length + 1).join(pad) + str;    
};
String.prototype.rpad = function(count, pad) {
  pad = pad || '0';
  str = this + '';
  return str.length >= count ? str : str + new Array(count - str.length + 1).join(pad);    
...
lpad(count, pad)
String.prototype.lpad = function(count, pad) {
    pad = pad || '0';
    str = this + '';
    return str.length >= count ? str : new Array(count - str.length + 1).join(pad) + str;
};
lpad(l)
String.prototype.lpad = function(l) {
  var s = this;
  while (s.length < l) { s = "0"+s; }
  return s;
lpad(len, padstr)
String.prototype.lpad = function(len, padstr) {
  return Array(len + 1 - this.length).join(padstr) + this;
};
String.prototype.rpad = function(len, padstr) {
  return this + Array(len + 1 - this.length).join(padstr);
};
lpad(len, s)
String.prototype.lpad = function(len, s) {   
    var a = new Array(this);   
    var n = (len - this.length);   
    for ( var i = 0; i < n; i++) {   
        a.unshift(s);   
    return a.join("");   
};
lpad(length, padString)
String.prototype.lpad = function(length, padString){
    var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
};
lpad(pSize, pCharPad)
String.prototype.lpad = function(pSize, pCharPad)
  var str = this;
  var dif = pSize - str.length;
  var ch = String(pCharPad).charAt(0);
  for (; dif>0; dif--) str = ch + str;
  return (str);
lpad(pad, length)
function fill(num) {
    return (num == 10 ? '' : '0') + num;
String.prototype.lpad = function(pad, length) {
    var s = this;
    while (s.length < length) {
        s = pad + s;
    return s;
...