Nodejs Utililty Methods String Sprintf

List of utility methods to do String Sprintf

Description

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

Method

sprintf
String.prototype.sprintf = 
String.prototype.format = function(){
    var arr = Array.prototype.slice.call( arguments, 0 ),
        i = 1,
        ii = arr.length,
        s = this;
    s = s.replace( /%s/g, function(){
        return '{%' + i++ + '%}';
    });
...
sprintf()
String.prototype.sprintf = function() {
  var formatted = this;
  for (var i = 0; i < arguments.length; i++) {
    var regexp = new RegExp('\\{'+i+'\\}', 'gi');
    formatted = formatted.replace(regexp, arguments[i]);
  return formatted;
};
sprintf()
String.prototype.sprintf = function () {
  if(!arguments.length) return this.split('%s').join('');
  var text=this.split('%s'),result=text.shift();
  $.each(arguments, function(i, value){
    if(!text.length) return result;
    result = result + value+text.shift();
  });
  if(text.length) result=result+text.join('');
  return result;
...