Nodejs String Padding Right rpad(padString, length)

Here you can find the source of rpad(padString, length)

Method Source Code

//pads right//from  w  w  w . j a v a  2  s.co  m
String.prototype.rpad = function(padString, length) {
   var str = this;
   while(str.length < length)
      str = str + padString;
   return str;
}

Related

  1. padRight(max, c)
    if (!String.prototype.padRight) {
      String.prototype.padRight = function(max, c) {
        var self = this;
        return self + new Array(Math.max(0, max - self.length + 1)).join(c || ' ');
      };
    
  2. padRight(n, c)
    String.prototype.padRight = function(n, c) {
      var len = this.length;
      ch = c || ' ';
      if (n <= len) {
        return this;
      else {
        var s = this;
        for (var i=0; i < n - len; i++) {
    ...
    
  3. rpad(character, count)
    String.prototype.rpad = 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 this+s;
    
  4. rpad(count, pad)
    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);
    };
    
  5. rpad(padString, length)
    'use strict';
    String.prototype.rpad = function(padString, length) {
      var str = this;
      while (str.length < length) {
        str = str + padString;
      return str;
    };
    
  6. rpad(padString, length)
    String.prototype.rpad = function(padString, length) {
      var str = this;
        while (str.length < length){
            str = str + padString;
        return str;
    
  7. rpad(padString, length)
    String.prototype.rpad = function(padString, length) {
      var str = this;
        while (str.length < length)
            str = str + padString;
        return str;
    };
    
  8. rpad(padString, length)
    String.prototype.rpad = function(padString, length) {
      var str = this;
        while (str.length < length)
            str = str + padString;
        return str;
    
  9. rpad(pad_str, length)
    String.prototype.rpad = function(pad_str, length) {
      var str = this;
      while (str.length < length) str = str + pad_str;
      return str;