Files
cdnjs/ajax/libs/string.js/0.2.1/string.min.js
T

1 line
5.2 KiB
JavaScript

((function(){function f(a,b){var c={},d={},e,f={},g={},h={},i={};f[0]="HTML_SPECIALCHARS",f[1]="HTML_ENTITIES",g[0]="ENT_NOQUOTES",g[2]="ENT_COMPAT",g[3]="ENT_QUOTES",h=isNaN(a)?a?a.toUpperCase():"HTML_SPECIALCHARS":f[a],i=isNaN(b)?b?b.toUpperCase():"ENT_COMPAT":g[b];if(h!=="HTML_SPECIALCHARS"&&h!=="HTML_ENTITIES")throw new Error("Table: "+h+" not supported");c[38]="&amp;",h==="HTML_ENTITIES"&&(c[160]="&nbsp;",c[161]="&iexcl;",c[162]="&cent;",c[163]="&pound;",c[164]="&curren;",c[165]="&yen;",c[166]="&brvbar;",c[167]="&sect;",c[168]="&uml;",c[169]="&copy;",c[170]="&ordf;",c[171]="&laquo;",c[172]="&not;",c[173]="&shy;",c[174]="&reg;",c[175]="&macr;",c[176]="&deg;",c[177]="&plusmn;",c[178]="&sup2;",c[179]="&sup3;",c[180]="&acute;",c[181]="&micro;",c[182]="&para;",c[183]="&middot;",c[184]="&cedil;",c[185]="&sup1;",c[186]="&ordm;",c[187]="&raquo;",c[188]="&frac14;",c[189]="&frac12;",c[190]="&frac34;",c[191]="&iquest;",c[192]="&Agrave;",c[193]="&Aacute;",c[194]="&Acirc;",c[195]="&Atilde;",c[196]="&Auml;",c[197]="&Aring;",c[198]="&AElig;",c[199]="&Ccedil;",c[200]="&Egrave;",c[201]="&Eacute;",c[202]="&Ecirc;",c[203]="&Euml;",c[204]="&Igrave;",c[205]="&Iacute;",c[206]="&Icirc;",c[207]="&Iuml;",c[208]="&ETH;",c[209]="&Ntilde;",c[210]="&Ograve;",c[211]="&Oacute;",c[212]="&Ocirc;",c[213]="&Otilde;",c[214]="&Ouml;",c[215]="&times;",c[216]="&Oslash;",c[217]="&Ugrave;",c[218]="&Uacute;",c[219]="&Ucirc;",c[220]="&Uuml;",c[221]="&Yacute;",c[222]="&THORN;",c[223]="&szlig;",c[224]="&agrave;",c[225]="&aacute;",c[226]="&acirc;",c[227]="&atilde;",c[228]="&auml;",c[229]="&aring;",c[230]="&aelig;",c[231]="&ccedil;",c[232]="&egrave;",c[233]="&eacute;",c[234]="&ecirc;",c[235]="&euml;",c[236]="&igrave;",c[237]="&iacute;",c[238]="&icirc;",c[239]="&iuml;",c[240]="&eth;",c[241]="&ntilde;",c[242]="&ograve;",c[243]="&oacute;",c[244]="&ocirc;",c[245]="&otilde;",c[246]="&ouml;",c[247]="&divide;",c[248]="&oslash;",c[249]="&ugrave;",c[250]="&uacute;",c[251]="&ucirc;",c[252]="&uuml;",c[253]="&yacute;",c[254]="&thorn;",c[255]="&yuml;"),i!=="ENT_NOQUOTES"&&(c[34]="&quot;"),i==="ENT_QUOTES"&&(c[39]="&#39;"),c[60]="&lt;",c[62]="&gt;";for(e in c)c.hasOwnProperty(e)&&(d[String.fromCharCode(e)]=c[e]);return d}var a,b,c,d,e;a=function(){function a(a){this.s=a,this.s==null&&(this.s=this)}return a.prototype.camelize=function(){var b;return b=this.trim().s.replace(/(\-|_|\s)+(.)?/g,function(a,b,c){return c?c.toUpperCase():""}),new a(b)},a.prototype.capitalize=function(){return new a(this.s.substr(0,1).toUpperCase()+this.s.substring(1).toLowerCase())},a.prototype.collapseWhitespace=function(){var b;return b=this.s.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,""),new a(b)},a.prototype.contains=function(a){return this.s.indexOf(a)>=0},a.prototype.dasherize=function(){var b;return b=this.trim().s.replace(/[_\s]+/g,"-").replace(/([A-Z])/g,"-$1").replace(/-+/g,"-").toLowerCase(),new a(b)},a.prototype.decodeHtmlEntities=function(b){var c,d,e,g;d={},e=c="",g=this.s;if(!1===(d=f("HTML_ENTITIES",b)))return!1;delete d["&"],d["&"]="&amp;",console.log(g);for(e in d)c=d[e],g=g.split(c).join(e);return g=g.split("&#039;").join("'"),new a(g)},a.prototype.endsWith=function(a){var b;return b=this.s.length-a.length,b>=0&&this.s.indexOf(a,b)===b},a.prototype.isAlpha=function(){return!/[^a-zA-Z]/.test(this.s)},a.prototype.isAlphaNumeric=function(){return!/[^a-zA-Z0-9]/.test(this.s)},a.prototype.isEmpty=function(){return/^[\s\xa0]*$/.test(this.s)},a.prototype.isLower=function(){return!/[^a-z]/.test(this.s)},a.prototype.isNumeric=function(){return!/[^0-9]/.test(this.s)},a.prototype.isUpper=function(){return!/[^A-Z]/.test(this.s)},a.prototype.left=function(b){var c;return b>=2?(c=this.s.substr(0,b),new a(c)):this.right(-b)},a.prototype.ltrim=function(){var b;return b=this.s.replace(/(^\s*)/g,""),new a(b)},a.prototype.replaceAll=function(b,c){var d;return d=this.s.replace(new RegExp(b,"g"),c),new a(d)},a.prototype.right=function(b){var c;return b>=0?(c=this.s.substr(this.s.length-b,b),new a(c)):this.left(-b)},a.prototype.rtrim=function(){var b;return b=this.s.replace(/\s+$/,""),new a(b)},a.prototype.startsWith=function(a){return this.s.lastIndexOf(a,0)===0},a.prototype.times=function(b){return new a((new Array(b+1)).join(this.s))},a.prototype.trim=function(){var b;return typeof String.prototype.trim=="undefined"?b=this.s.replace(/(^\s*|\s*$)/g,""):b=this.s.trim(),new a(b)},a.prototype.toString=function(){return this.s},a.prototype.underscore=function(){var b;return b=this.trim().s.replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase(),(new a(this.s.charAt(0))).isUpper()&&(b="_"+b),new a(b)},a.prototype.repeat=a.prototype.times,a.prototype.include=a.prototype.contains,a}(),e=function(b){return new a(b)},c=[],b=function(){var b,d,e,f;e=new a,f=[];for(d in e)b=e[d],String.prototype.hasOwnProperty(d)?f.push(void 0):(c.push(d),f.push(String.prototype[d]=function(){return String.prototype.s=this,b.apply(this,arguments)}));return f},d=function(){var a,b,d;for(b=0,d=c.length;b<d;b++)a=c[b],delete String.prototype[a];return c.length=0},typeof window!="undefined"&&window!==null?(window.S=e,window.S.clobberPrototype=b,window.S.restorePrototype=d):(module.exports=e,module.exports.clobberPrototype=b,module.exports.restorePrototype=d)})).call(this);