Here you can find the source of format(data)
String.prototype.format = function(data) { return this.replace(/{(.+?)}/g, function(match, name) { return data[name] || match; });/*w ww . j av a 2 s.c o m*/ };
'use strict'; String.prototype.format = function (args) { if (arguments.length>0) { var result = this; console.log(this) if (arguments.length ==1 && typeof(args)=="object") { for(var key in args){ var reg = new RegExp ("({"+key+"})","g"); result = result.replace(reg,args[key]); ...
String.prototype.format = function(args) var result = this; if (arguments.length > 0) var reg; if (arguments.length == 1 && typeof(args) == "object") for (var key in args) ...
String.prototype.format = function (args) { var newStr = this; for (var key in args) { newStr = newStr.replace('{' + key + '}', args[key]); return newStr;
String.prototype.format = function(args, index) { return this.replace(/{(\w+)}/g, function(match, number) { return typeof args[index[number]] != 'undefined' ? args[index[number]] : match ; }); };
String.prototype.format = function (ctx) { return this.replace(/\$\{([\w\.]+)\}/g, function(all, varname) { var keys = varname.split('.'); var val = null; for (var i = 0, len = keys.length; i < len; i++) { val = ctx[keys[i]]; return val; }); ...
String.prototype.format = function(dict) { var result = this; if(typeof(dict) === "object") { Object.keys(dict).forEach(function(key) { result = result.replace("{" + key + "}", dict[key]); }); return result; var args = []; ...
String.prototype.format = function (fmt) { if (fmt==null) fmt = "yyyy-MM-dd"; var myDate = new Date(this); var o = { "M+": myDate.getMonth() + 1, "d+": myDate.getDate(), "h+": myDate.getHours(), "m+": myDate.getMinutes(), "s+": myDate.getSeconds(), ...
String.prototype.format = function (format) { const holders = JSON.parse(format), regex = new RegExp('(#{(\\w+)})', 'g'); let transformed = this, currentMatch = ''; while ((currentMatch = regex.exec(this)) !== null) { transformed = transformed.replace(currentMatch[1], holders[currentMatch[2]]); return transformed; ...
String.format = function (format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); }; String.prototype.format = function () { ...