Files

1 line
2.8 KiB
JavaScript

((function(){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.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);