format/format-min.js
2013-04-05 23:59:37 -07:00

3 lines
1.1 KiB
JavaScript

(function(){function k(){console.log(e.apply(null,arguments))}function e(h){for(var f=1,e=[].slice.call(arguments),g=0,d=h.length,a="",b,l=!1,m,c=function(){return e[f++]},k=function(){for(var a="";h[g].match(/\d/);)a+=h[g++];return 0<a.length?parseInt(a):null};g<d;++g)if(b=h[g],l)switch(l=!1,m=k(),b){case "b":a+=parseInt(c(),10).toString(2);break;case "c":b=c();a="string"===typeof b||b instanceof String?a+b:a+String.fromCharCode(parseInt(b,10));break;case "d":a+=parseInt(c(),10);break;case "f":a+=
parseFloat(c()).toFixed(m||6);break;case "o":a+="0"+parseInt(c(),10).toString(8);break;case "s":a+=c();break;case "x":a+="0x"+parseInt(c(),10).toString(16);break;case "X":a+="0x"+parseInt(c(),10).toString(16).toUpperCase();break;default:a+=b}else"%"===b?l=!0:a+=b;return a}var d;d="undefined"!==typeof module?module.exports=e:function(){return this||(0,eval)("this")}();d.format=e;d.vsprintf=function(d,f){f instanceof Array||(f=[].slice.call(arguments,1));return e.apply(null,[d].concat(f))};"undefined"!==
typeof console&&"function"===typeof console.log&&(d.printf=k)})();