Nodejs String Padding Left padl(ch, len)

Here you can find the source of padl(ch, len)

Method Source Code

'use strict';//w w w . j  a v  a  2 s. co m

String.prototype.padl = function(ch, len) {
    var s = this;
    while (s.length < len) {
        s = ch + s;
    }
    return s;
};

Related

  1. padLeft(padString,length)
    String.prototype.padLeft = function(padString,length){
        var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    
  2. padLeft(paddingValue)
    String.prototype.padLeft = function (paddingValue) {
      return String(paddingValue + this).slice(-paddingValue.length);
    };
    
  3. padLeft(size, char)
    String.prototype.padLeft = function (size, char) {
        if (size === 0) {
            return '';
        return (Array(size + 1).join(char) + this).slice(-size);
    };
    
  4. padLeft(size, prefix)
    (function(){
    String.prototype.padLeft = function(size, prefix) {
        prefix = prefix || " ";
        var s = ''+this;
        while (s.length < size) s = prefix + s;
        return s;
    };
    Math.randInt = function(min, max){
      return Math.floor(Math.random() * (max - min + 1)) + min;
    ...
    
  5. padLeft(totalLength, value)
    String.prototype.padLeft = function (totalLength, value) {
      if (this.length >= totalLength)
        return this;
      var str = this;
      while (str.length < totalLength)
        str = value + str;
      return str;
    };
    
  6. padl(ch, len)
    String.prototype.padl = function(ch, len) {
        var s = this;
        while (s.length < len) {
            s = ch + s;
        return s;
    };
    
  7. paddingLeft(paddingValue)
    String.prototype.paddingLeft = function(paddingValue)
      return String(paddingValue + this).slice(-paddingValue.length);
    };
    
  8. leftPad(character, totalLength)
    String.prototype.leftPad = function (character, totalLength) {
        var s = this;
        while (s.length < totalLength)
            s = character + s;
        return s;
    
  9. leftPad(l, c)
    String.prototype.leftPad = function (l, c) { 
      return new Array(l - this.length + 1).join(c || ' ') + this;