Here you can find the source of rpad(character, count)
/** /*from w w w .j av a 2 s .c o m*/ * Right pad * @param {string} [character="0"] * @param {int} [count=2] */ 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; }
String.prototype.padRight = function(count, character) { var ch = character || ' '; var result = this; for (var i = 0; i < count; i++) { result += ch; }; return result;
String.prototype.padRight = function(count, character) { character = character || ' ' ; return this.toString() + character.repeat(count); };
String.prototype.padRight = function(l,c) { var m = l; if(this.length > m) { m = ((this.length % m) + 1) * m; return this+Array(m-this.length+1).join(c||" "); }; var str = 'TextMustBe16Bytes'; console.log( ...
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 || ' '); };
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++) { ...
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); };
'use strict'; String.prototype.rpad = function(padString, length) { var str = this; while (str.length < length) { str = str + padString; return str; };
String.prototype.rpad = function(padString, length) { var str = this; while(str.length < length) str = str + padString; return str;
String.prototype.rpad = function(padString, length) { var str = this; while (str.length < length){ str = str + padString; return str;