Nodejs Utililty Methods String Fill

List of utility methods to do String Fill

Description

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

Method

fill(c, n)
String.prototype.fill = function(c, n) {
    var l = n - this.length;
    if (l <= 0) l = 1;
    return c.repeat(l).concat(this);
fill(char, count)
String.prototype.fill = function(char, count) {
  var charToPad = "";
  for(var index = 0; index < count; index++ ) {
    charToPad +=  char;
  return this + charToPad;
};
fill(o)
String.prototype.fill = function (o) {
    return this.replace(/{([^{}]*)}/g,
        function (a, b) {
            var r = o[b];
            return typeof r === 'string' || typeof r === 'number' ? r : a;
    );
};