Comparing version 0.3.1 to 0.3.2
{ | ||
"name": "words.js", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "A flexible, robust and powerful Javascript word-string manipulation library.", | ||
@@ -29,6 +29,4 @@ "main": "words.min.js", | ||
"homepage": "https://github.com/phazelift/words.js", | ||
"dependencies": { | ||
"strings.js" : "1.2.2" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
} |
words.js | ||
======== | ||
Only 5.7Kb minified (depends on strings.js), words.js is a toolbox for manipulating words from a space seperated string. | ||
Great for text input or command-line parsing, educational tools, word-games, text filters, password generators, etc.. | ||
words.js is a toolbox for manipulating the words in a string. Great for handling command-line or text input, | ||
educational tools, word-games, text filters, password generators, etc.. | ||
<br/> | ||
@@ -46,3 +46,2 @@ | ||
__________________________________ | ||
**words.js depends on, and extends strings.js**, so, for browser use: load strings.js before words.js in your index.html. | ||
@@ -75,5 +74,2 @@ Most methods overload strings.js methods, only to focus on words rather than characters. | ||
types.js, strings.js and words.js are a very powerful set of building blocks that can make the life of a Javascript | ||
developer much more pleasant and bug free IMHO. | ||
All input and output is type save; you can throw in any type and still get a string if the expected output is of | ||
@@ -389,2 +385,7 @@ type `<string>`. If any method receives an argument of a type it cannot process, the argument will simply be ignored. | ||
**0.3.2** | ||
Removed strings.js dependency. types.js (1.4.2) and strings.js (1.2.2) are now included in words.js | ||
___ | ||
**0.3.0** | ||
@@ -391,0 +392,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var t,r,n,e,i,o,u,s,c,f,a,p,g,l={}.hasOwnProperty,h=function(t,r){function n(){this.constructor=t}for(var e in r)l.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t},m=[].slice,y=[].indexOf||function(t){for(var r=0,n=this.length;n>r;r++)if(r in this&&this[r]===t)return r;return-1};s=function(){var t;return t=new Number,t["void"]=!0,t},n={parseIntBase:10},c={Boolean:!1,String:"",Number:s(),Object:{},Array:[],Function:function(){}},u=function(t){var r;return r=function(r){switch(t){case"Number":if(n.isNumber(r=parseInt(r,n.parseIntBase)))return r;break;case"String":if(n.isStringOrNumber(r))return r+"";break;default:if(n["is"+t](r))return r}return!1},function(n,e){return!1!==(n=r(n))?n:!1!==(e=r(e))?e:c[t]}},a=function(t,r,n){var e,i,o;if(null==n&&(n=[]),n.length<1)return t===p.Undefined?!0:!1;for(i=0,o=n.length;o>i;i++)if(e=n[i],t(e)===r)return r;return!r},p={Undefined:function(t){return void 0===t},Null:function(t){return null===t},Boolean:function(t){return"boolean"==typeof t},String:function(t){return"string"==typeof t},Function:function(t){return"function"==typeof t},Number:function(t){return"number"==typeof t&&t===t||"object"==typeof t&&t instanceof Number&&t["void"]},Array:function(t){return"object"==typeof t&&t instanceof Array},RegExp:function(t){return"object"==typeof t&&t instanceof RegExp},Date:function(t){return"object"==typeof t&&t instanceof Date},Object:function(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof RegExp||t instanceof Date)},NaN:function(t){return"number"==typeof t&&t!==t},Defined:function(t){return void 0!==t}},p.StringOrNumber=function(t){return p.String(t)||p.Number(t)},i=!0,function(){var t,r,e;e=[];for(t in p)r=p[t],e.push(function(t,r){return n["is"+t]=r,n["not"+t]=function(t){return!r(t)},n["has"+t]=function(){return a(r,i,arguments)},n["all"+t]=function(){return a(r,!i,arguments)},t in c?n["force"+t]=u(t):void 0}(t,r));return e}(),n["typeof"]=function(t){var r,n;for(n in p)if(r=p[n],r(t)===!0)return n.toLowerCase();return"unknown"},f=function(t){var r,n,e,i,o;if(g.notArray(t))return 0;for(r=i=0,o=t.length;o>i;r=++i){if(e=t[r],n=g.forceNumber(e),n["void"])return r;t[r]=n}return t.length},g=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return h(r,t),r.inRange=function(t,n){return r.isNaN(t=parseInt(t,10))||f(n)<2?!1:t>=n[0]&&t<=n[1]},r.limitNumber=function(t,n){return t=r.forceNumber(t,0),f(n)<2?t:t<n[0]?n[0]:t>n[1]?n[1]:t},r.randomNumber=function(t,r){return f([t,r])<2?0:t>r?t:(r=r-t+1,Math.floor(Math.random()*r+t))},r.shuffleArray=function(t){var n,e,i,o,u;if(r.notArray(t)||t.length<1)return[];for(e=t.length-1,n=u=e;0>=e?0>=u:u>=0;n=0>=e?++u:--u)i=r.randomNumber(0,n),o=t[n],t[n]=t[i],t[i]=o;return t},r.positiveIndex=function(t,n){return 0===(t=r.forceNumber(t,0))?!1:(n=Math.abs(r.forceNumber(n)),Math.abs(t)<=n?t>0?t-1:n+t:!1)},r.insertSort=function(t){var r,n,e,i,o;for(e=t.length-1,n=o=1;e>=1?e>=o:o>=e;n=e>=1?++o:--o){for(r=t[n],i=n-1;i>=0&&t[i]>r;)t[i+1]=t[i],--i;t[+i+1]=r}return t},r.noDupAndReverse=function(t){var r,n,e,i;for(n=t.length-1,e=[],r=i=n;0>=n?0>=i:i>=0;r=0>=n?++i:--i)e[e.length-1]!==t[r]&&e.push(t[r]);return e},r.sortNoDupAndReverse=function(t,n){var e,i,o,u,s;for(i=[],e=u=0,s=t.length;s>u;e=++u)o=t[e],o=r.forceNumber(o),o["void"]||(n>=o&&(o=r.positiveIndex(o,n)),i.push(r.forceNumber(o,0)));return r.noDupAndReverse(r.insertSort(i))},r}(n),t=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return h(r,t),r.ASCII_RANGE_UPPERCASE=[65,90],r.ASCII_RANGE_LOWERCASE=[97,122],r.ASCII_RANGE_NUMBERS=[48,57],r.ASCII_RANGE_ALL=[32,126],r.REGEXP_SPECIAL_CHARS=["?","\\","[","]","(",")","*","+",".","/","|","^","$","<",">","-","&"],r.ascii=function(t){return String.fromCharCode(g.forceNumber(t))},r.ordinal=function(t){return g.forceNumber(g.forceString(t).charCodeAt(),0)},r.isUpper=function(t){return g.inRange(r.ordinal(t),r.ASCII_RANGE_UPPERCASE)},r.isLower=function(t){return g.inRange(r.ordinal(t),r.ASCII_RANGE_LOWERCASE)},r.isAlpha=function(t){return r.isUpper(t)||r.isLower(t)},r.isNumeric=function(t){return g.inRange(r.ordinal(t),r.ASCII_RANGE_NUMBERS)},r.isSpecial=function(t){return g.inRange(r.ordinal(t),r.ASCII_RANGE_ALL)&&!(r.isAlphaNumeric(t)||" "===t)},r.isAlphaNumeric=function(t){return r.isAlpha(t)||r.isNumeric(t)},r.random=function(t){var n,e;return t=g.forceArray(t,r.ASCII_RANGE_ALL),e=g.limitNumber(t[0],t),n=g.limitNumber(t[1],t),r.ascii(g.randomNumber(e,n))},r}(g),o=function(){var t,n,e,i,o,u,s,c,f;if(o=arguments[0],e=arguments[1],n=3<=arguments.length?m.call(arguments,2):[],null==o&&(o=""),""===(o=g.forceString(o)))return o;if(n.length<1||void 0===n[0])return o[e]();if(g.isNumber(n[0]))for(u=0,c=n.length;c>u;u++)t=n[u],i=g.positiveIndex(t,o.length),o=r.xs(o,function(t,r){return r===i?t[e]():t});else if(g.isString(n[0]))for(s=0,f=n.length;f>s;s++)t=n[s],o=r.replace(o,t,t[e](),"gi");return o},e=function(t,r){var n,e,i;if(""===(t=g.forceString(t)))return!1;for(e=0,i=t.length;i>e;e++)if(n=t[e],!r(n))return!1;return!0},r=function(r){function n(){this.set.apply(this,arguments),this.wrapMethod=null,this.crop=this.slice}return h(n,r),n.create=function(){var t,r,n,e;for(r="",n=0,e=arguments.length;e>n;n++)t=arguments[n],r+=g.forceString(t);return r},n.get=function(){var t,r,n,e,i,o,u;if(o=arguments[0],e=2<=arguments.length?m.call(arguments,1):[],arguments.length<2)return"";for(o=g.forceString(o),r=o.length,i="",t=arguments.length,n=u=1;t>=1?t>=u:u>=t;n=t>=1?++u:--u)n=g.positiveIndex(arguments[n],r),n!==!1&&(i+=o[n]);return i},n.sort=function(t){return t=g.forceString(t).trim().split(""),g.insertSort(t).join("")},n.random=function(r,n){var e,i,o;for(r=g.forceNumber(r,1),i="",e=o=1;r>=1?r>=o:o>=r;e=r>=1?++o:--o)i+=t.random(n);return i},n.times=function(t,r){var n;if(""===(t=g.forceString(t)))return"";for(r=g.forceNumber(r,1),n="";r-->0;)n+=t;return n},n.regEscape=function(r){return""===(r=g.forceString(r))?r:n.xs(r,function(r){return y.call(t.REGEXP_SPECIAL_CHARS,r)>=0?"\\"+r:!0})},n.empty=function(t){return g.notString(t)||t.length>0?!1:!0},n.isAlpha=function(r){return e(r,t.isAlpha)},n.isNumeric=function(r){return e(r,t.isNumeric)},n.isAlphaNumeric=function(r){return e(r,t.isAlphaNumeric)},n.isSpecial=function(r){return e(r,t.isSpecial)},n.isSpace=function(t){return/^[ \t]+$/g.test(t)},n.xs=function(t,r){var n,e,i,o,u;if(null==t&&(t=""),t=g.forceString(t),-1===(e=t.length-1))return"";for(r=g.forceFunction(r,function(t){return t}),o="",n=u=0;e>=0?e>=u:u>=e;n=e>=0?++u:--u)(i=r(t[n],n))&&(i===!0?o+=t[n]:g.isStringOrNumber(i)&&(o+=i));return o},n.copy=function(t,r,n){return r=g.forceNumber(r),""===(t=g.forceString(t))||Math.abs(r)>t.length?"":(r>0&&(r-=1),t.substr(r,g.forceNumber(n,t.length)))},n.replace=function(t,r,e,i){var o;return null==t&&(t=""),null==r&&(r=""),null==e&&(e=""),null==i&&(i="g"),!g.isStringOrNumber(t)||"string"!==(o=g["typeof"](r))&&"number"!==o&&"regexp"!==o?g.forceString(t):(g.notRegExp(r)&&(r=n.regEscape(r+""),r=new RegExp(r,i)),(t+"").replace(r,e))},n.trim=function(t){return n.replace(t,/^\s+|\s+$/g)},n.trimLeft=function(t){return n.replace(t,/^\s+/g)},n.trimRight=function(t){return n.replace(t,/\s+$/g)},n.oneSpace=function(t){return n.replace(t,/\s+/g," ")},n.oneSpaceAndTrim=function(t){return n.oneSpace(n.trim(t))},n.toCamel=function(t,r){var e;return t=g.forceString(t),r=g.forceString(r,"-"),e=new RegExp(n.regEscape(r)+"([a-z])","ig"),n.replace(t,e,function(t,r){return r.toUpperCase()})},n.unCamel=function(t,r){return t=g.forceString(t),r=g.forceString(r,"-"),n.replace(t,/([A-Z])/g,r+"$1").toLowerCase()},n.shuffle=function(t){return t=g.forceString(t),g.shuffleArray((t+"").split("")).join("")},n.find=function(t,r,e){var i,o;if(i=[],""===(t=g.forceString(t)))return i;if(e=g.forceString(e,"g"),g.isStringOrNumber(r))r=new RegExp(n.regEscape(r+""),e);else{if(!g.isRegExp(r))return i;r=new RegExp(r.source,e)}if(r.global)for(;o=r.exec(t);)i.push(o.index+1);else(o=r.exec(t))&&i.push(o.index+1);return i},n.count=function(t,r){return n.find(t,r).length},n.contains=function(t,r){return n.count(t,r)>0},n.between=function(t,r,e){var i,o;return g.allStringOrNumber(t,r,e)?(r=n.regEscape(r+""),e=n.regEscape(e+""),i=new RegExp(r+"(.+)"+e),(null!=(o=i.exec(t+""))?o[1]:void 0)||""):""},n.slice=function(t,r,n){return t=g.forceString(t),r=g.forceNumber(r||1),!1!==(r=g.positiveIndex(r,t.length))?(n=g.forceNumber(n),t.slice(r,r+n)):""},n.truncate=function(t,r,e){return t=g.forceString(t),r=g.forceNumber(r,t.length),t=n.slice(t,1,r),t+g.forceString(e)},n.pop=function(t,r){return t=g.forceString(t),r=g.forceNumber(r,1),t.slice(0,-Math.abs(r))},n.split=function(t,r){var e,i,o,u,s;if(t=n.oneSpaceAndTrim(t),i=[],t.length<1)return i;for(r=g.forceString(r," "),e=t.split(r[0]||""),u=0,s=e.length;s>u;u++)o=e[u],o.match(/^\s$/)||i.push(n.trim(o));return i},n.reverse=function(t){var r,n,e,i;if(null==t&&(t=""),t=g.forceString(t),(n=t.length-1)<1)return t;for(e="",r=i=n;0>=n?0>=i:i>=0;r=0>=n?++i:--i)e+=t[r];return e},n.upper=function(){var t,r;return r=arguments[0],t=2<=arguments.length?m.call(arguments,1):[],o.apply(null,[r,"toUpperCase"].concat(m.call(t)))},n.lower=function(){var t,r;return r=arguments[0],t=2<=arguments.length?m.call(arguments,1):[],o.apply(null,[r,"toLowerCase"].concat(m.call(t)))},n.insert=function(){var t,r,n,e,i,o;if(i=arguments[0],r=arguments[1],e=3<=arguments.length?m.call(arguments,2):[],""===(i=g.forceString(i))||""===(r=g.forceString(r)))return i;if(e=g.sortNoDupAndReverse(e,i.length),n=f(e)-1,0>n)return i;for(t=o=0;n>=0?n>=o:o>=n;t=n>=0?++o:--o)t=e[t],t>i.length?i+=r:i=i.substr(0,t)+r+i.substr(t);return i},n.removeRange=function(t,r,e){var i;return t=g.forceString(t),""===t||!1===(r=g.positiveIndex(r,t.length))||0>(e=g.forceNumber(e,1))?t:(i=r+e,n.xs(t,function(t,n){return r>n||n>=i?!0:void 0}))},n.removePos=function(){var t,r,e;return e=arguments[0],r=2<=arguments.length?m.call(arguments,1):[],""===(e=g.forceString(e))?"":(t=r.map(function(t){return g.positiveIndex(t,e.length)}),n.xs(e,function(r,n){return y.call(t,n)>=0?void 0:!0}))},n.remove=function(){var t,r,e,i,o;if(r=arguments[0],e=2<=arguments.length?m.call(arguments,1):[],null==r&&(r=""),""===(r=g.forceString(r))||e.length<1)return r;for(i=0,o=e.length;o>i;i++)t=e[i],r=n.replace(r,t);return r},n.startsWith=function(t,r){return 1===n.find(t,r)[0]},n.endsWith=function(t,r){return""===(t=g.forceString(t))||""===(r=g.forceString(r))?!1:(r=new RegExp(n.regEscape(r)+"$"),r.test(t))},n.wrap=function(t,r){var e;return null==t&&(t=""),null==r&&(r=""),e=function(e){return n.create(t,e,r)},e.wrap=function(n,e){return null==n&&(n=""),null==e&&(e=""),t=g.forceString(n)+t,r+=g.forceString(e)},e},n.prototype.set=function(){return this.string=n.create.apply(this,arguments),this},n.prototype.sort=function(){return this.string=n.sort(this.string),this},n.prototype.random=function(t,r){return this.string=n.random(t,r),this},n.prototype.xs=function(t){return this.string=n.xs(this.string,t),this},n.prototype.times=function(t){return null==t&&(t=1),this.string=n.times(this.string,t),this},n.prototype.get=function(){var t,r,n,e;if(arguments.length>0){for(r="",n=0,e=arguments.length;e>n;n++)t=arguments[n],t=g.positiveIndex(t,this.length),t!==!1&&(r+=this.string[t]);return r}return this.string},n.prototype.copy=function(t,r){return n.copy(this.string,t,r)},n.prototype.empty=function(){return n.empty(this.string)},n.prototype.isAlpha=function(){return n.isAlpha(this.string)},n.prototype.isNumeric=function(){return n.isNumeric(this.string)},n.prototype.isAlphaNumeric=function(){return n.isAlphaNumeric(this.string)},n.prototype.isSpecial=function(){return n.isSpecial(this.string)},n.prototype.isSpace=function(){return n.isSpace(this.string)},n.prototype.push=function(){return this.string=this.string+n.create.apply(this,arguments),this},n.prototype.prepend=function(){return this.string=n.create.apply(this,arguments)+this.string,this},n.prototype.pop=function(t){return this.string=n.pop(this.string,t),this},n.prototype.insert=function(){var t,r;return r=arguments[0],t=2<=arguments.length?m.call(arguments,1):[],this.string=n.insert.apply(n,[this.string,r].concat(m.call(t))),this},n.prototype.trim=function(){return this.string=n.trim(this.string),this},n.prototype.trimLeft=function(){return this.string=n.trimLeft(this.string),this},n.prototype.trimRight=function(){return this.string=n.trimRight(this.string),this},n.prototype.oneSpace=function(){return this.string=n.oneSpace(this.string),this},n.prototype.oneSpaceAndTrim=function(){return this.string=n.oneSpaceAndTrim(this.string),this},n.prototype.find=function(t){return n.find(this.string,t)},n.prototype.count=function(t){return n.count(this.string,t)},n.prototype.contains=function(t){return n.contains(this.string,t)},n.prototype.between=function(t,r){return n.between(this.string,t,r)},n.prototype.slice=function(t,r){return this.string=n.slice(this.string,t,r),this},n.prototype.truncate=function(t,r){return this.string=n.truncate(this.string,t,r),this},n.prototype.remove=function(){var t;return t=1<=arguments.length?m.call(arguments,0):[],this.string=n.remove.apply(n,[this.string].concat(m.call(t))),this},n.prototype.removeRange=function(t,r){return this.string=n.removeRange(this.string,t,r),this},n.prototype.removePos=function(){var t;return t=1<=arguments.length?m.call(arguments,0):[],this.string=n.removePos.apply(n,[this.string].concat(m.call(t))),this},n.prototype.replace=function(t,r,e){return this.string=n.replace(this.string,t,r,e),this},n.prototype.reverse=function(){return this.string=n.reverse(this.string),this},n.prototype.upper=function(){var t;return t=1<=arguments.length?m.call(arguments,0):[],this.string=n.upper.apply(n,[this.string].concat(m.call(t))),this},n.prototype.lower=function(){var t;return t=1<=arguments.length?m.call(arguments,0):[],this.string=n.lower.apply(n,[this.string].concat(m.call(t))),this},n.prototype.shuffle=function(){return this.string=n.shuffle(this.string),this},n.prototype.toCamel=function(t){return this.string=n.toCamel(this.string,t),this},n.prototype.unCamel=function(t){return this.string=n.unCamel(this.string,t),this},n.prototype.startsWith=function(t){return n.startsWith(this.string,t)},n.prototype.endsWith=function(t){return n.endsWith(this.string,t)},n.prototype.setWrap=function(t,r){return g.isNull(this.wrapMethod)?this.wrapMethod=n.wrap(t,r):this.wrapMethod.wrap(t,r),this},n.prototype.removeWrap=function(){return this.wrapMethod=null,this},n.prototype.applyWrap=function(t,r){return this.string=this.setWrap(t,r).wrap,this.removeWrap(),this},n}(t),Object.defineProperty(r.prototype,"$",{get:function(){return this.get()}}),Object.defineProperty(r.prototype,"length",{get:function(){return this.string.length}}),Object.defineProperty(r.prototype,"wrap",{get:function(){return g.isNull(this.wrapMethod)?this.string:this.wrapMethod(this.string)}}),r.Types=n,r.Chars=t,r.crop=r.slice,r.prototype.crop=r.prototype.slice,r.prototype.append=r.prototype.push,"undefined"!=typeof window&&null!==window?window.Strings=r:module.exports=r}).call(this); | ||
(function(){"use strict";var t,r,n,e,i,o,u,s,c,f,a,p,g,l,h={}.hasOwnProperty,m=function(t,r){function n(){this.constructor=t}for(var e in r)h.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t},y=[].slice,S=[].indexOf||function(t){for(var r=0,n=this.length;n>r;r++)if(r in this&&this[r]===t)return r;return-1};f=function(t,r){return r instanceof t},g=function(t,r){return null==r&&(r="object"),typeof t===r},r={Boolean:!1,String:"",Object:{},Array:[],Function:function(){},Number:function(){var t;return t=new Number,t["void"]=!0,t}()},e={Undefined:function(t){return void 0===t},Null:function(t){return null===t},Function:function(t){return g(t,"function")},Boolean:function(t){return g(t,"boolean")},String:function(t){return g(t,"string")},Array:function(t){return g(t)&&f(Array,t)},RegExp:function(t){return g(t)&&f(RegExp,t)},Date:function(t){return g(t)&&f(Date,t)},Number:function(t){return g(t,"number")&&t===t||g(t)&&f(Number,t)},Object:function(t){return!(!g(t)||null===t||f(Boolean,t)||f(Number,t)||f(Array,t)||f(RegExp,t)||f(Date,t))},NaN:function(t){return g(t,"number")&&t!==t},Defined:function(t){return void 0!==t}},e.StringOrNumber=function(t){return e.String(t)||e.Number(t)},i=l={parseIntBase:10},c=function(t){var n;return n=function(r){switch(t){case"Number":if(l.isNumber(r=parseInt(r,l.parseIntBase))&&!r["void"])return r;break;case"String":if(l.isStringOrNumber(r))return r+"";break;default:if(i["is"+t](r))return r}},function(e,i){return null!=e&&void 0!==(e=n(e))?e:null!=i&&void 0!==(i=n(i))?i:r[t]}},p=function(t,r,n){var i,o,u;if(null==n&&(n=[]),n.length<1)return t===e.Undefined;for(o=0,u=n.length;u>o;o++)if(i=n[o],t(i)===r)return r;return!r},u=!0,function(){var t,n,o;o=[];for(t in e)n=e[t],o.push(function(t,n){return i["is"+t]=n,i["not"+t]=function(t){return!n(t)},i["has"+t]=function(){return p(n,u,arguments)},i["all"+t]=function(){return p(n,!u,arguments)},t in r?i["force"+t]=c(t):void 0}(t,n));return o}(),i["typeof"]=function(t){var r,n;for(r in e)if(n=e[r],n(t)===!0)return r.toLowerCase()},a=function(t){var r,n,e,i,o;if(l.notArray(t))return 0;for(r=i=0,o=t.length;o>i;r=++i){if(e=t[r],n=l.forceNumber(e),n["void"])return r;t[r]=n}return t.length},l=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return m(r,t),r.inRange=function(t,n){return r.isNaN(t=parseInt(t,10))||a(n)<2?!1:t>=n[0]&&t<=n[1]},r.limitNumber=function(t,n){return t=r.forceNumber(t,0),a(n)<2?t:t<n[0]?n[0]:t>n[1]?n[1]:t},r.randomNumber=function(t,r){return a([t,r])<2?0:t>r?t:(r=r-t+1,Math.floor(Math.random()*r+t))},r.shuffleArray=function(t){var n,e,i,o,u;if(r.notArray(t)||t.length<1)return[];for(e=t.length-1,n=u=e;0>=e?0>=u:u>=0;n=0>=e?++u:--u)i=r.randomNumber(0,n),o=t[n],t[n]=t[i],t[i]=o;return t},r.positiveIndex=function(t,n){return 0===(t=r.forceNumber(t,0))?!1:(n=Math.abs(r.forceNumber(n)),Math.abs(t)<=n?t>0?t-1:n+t:!1)},r.insertSort=function(t){var r,n,e,i,o;for(e=t.length-1,n=o=1;e>=1?e>=o:o>=e;n=e>=1?++o:--o){for(r=t[n],i=n-1;i>=0&&t[i]>r;)t[i+1]=t[i],--i;t[+i+1]=r}return t},r.noDupAndReverse=function(t){var r,n,e,i;for(n=t.length-1,e=[],r=i=n;0>=n?0>=i:i>=0;r=0>=n?++i:--i)e[e.length-1]!==t[r]&&e.push(t[r]);return e},r.sortNoDupAndReverse=function(t,n){var e,i,o,u,s;for(i=[],e=u=0,s=t.length;s>u;e=++u)o=t[e],o=r.forceNumber(o),o["void"]||(n>=o&&(o=r.positiveIndex(o,n)),i.push(r.forceNumber(o,0)));return r.noDupAndReverse(r.insertSort(i))},r}(i),t=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return m(r,t),r.ASCII_RANGE_UPPERCASE=[65,90],r.ASCII_RANGE_LOWERCASE=[97,122],r.ASCII_RANGE_NUMBERS=[48,57],r.ASCII_RANGE_SPECIAL_1=[32,47],r.ASCII_RANGE_SPECIAL_2=[58,64],r.ASCII_RANGE_SPECIAL_3=[91,96],r.ASCII_RANGE_SPECIAL_4=[123,126],r.ASCII_RANGE_ALL=[32,126],r.REGEXP_SPECIAL_CHARS=["?","\\","[","]","(",")","*","+",".","/","|","^","$","<",">","-","&"],r.ascii=function(t){return String.fromCharCode(l.forceNumber(t))},r.ordinal=function(t){return l.forceNumber(l.forceString(t).charCodeAt(),0)},r.random=function(t){var n,e;return t=l.forceArray(t,r.ASCII_RANGE_ALL),e=l.limitNumber(t[0],t),n=l.limitNumber(t[1],t),r.ascii(l.randomNumber(e,n))},r}(l),s=function(){var t,r,e,i,o,u,s,c,f;if(o=arguments[0],e=arguments[1],r=3<=arguments.length?y.call(arguments,2):[],null==o&&(o=""),""===(o=l.forceString(o)))return o;if(r.length<1||void 0===r[0])return o[e]();if(l.isNumber(r[0]))for(u=0,c=r.length;c>u;u++)t=r[u],i=l.positiveIndex(t,o.length),o=n.xs(o,function(t,r){return r===i?t[e]():t});else if(l.isString(r[0]))for(s=0,f=r.length;f>s;s++)t=r[s],o=n.replace(o,t,t[e](),"gi");return o},o=function(t,r){var n,e,i;if(""===(t=l.forceString(t)))return!1;for(e=0,i=t.length;i>e;e++)if(n=t[e],!r(n))return!1;return!0},n=function(r){function n(){this.set.apply(this,arguments),this.wrapMethod=null,this.crop=this.slice}return m(n,r),n.create=function(){var t,r,n,e;for(r="",n=0,e=arguments.length;e>n;n++)t=arguments[n],r+=l.forceString(t);return r},n.get=function(){var t,r,n,e,i,o,u;if(o=arguments[0],e=2<=arguments.length?y.call(arguments,1):[],arguments.length<2)return"";for(o=l.forceString(o),r=o.length,i="",t=arguments.length,n=u=1;t>=1?t>=u:u>=t;n=t>=1?++u:--u)n=l.positiveIndex(arguments[n],r),n!==!1&&(i+=o[n]);return i},n.sort=function(t){return t=l.forceString(t).trim().split(""),l.insertSort(t).join("")},n.random=function(r,n){var e,i,o;for(r=l.forceNumber(r,1),i="",e=o=1;r>=1?r>=o:o>=r;e=r>=1?++o:--o)i+=t.random(n);return i},n.times=function(t,r){var n;if(""===(t=l.forceString(t)))return"";for(r=l.forceNumber(r,1),n="";r-->0;)n+=t;return n},n.regEscape=function(r){return""===(r=l.forceString(r))?r:n.xs(r,function(r){return S.call(t.REGEXP_SPECIAL_CHARS,r)>=0?"\\"+r:!0})},n.empty=function(t){return l.notString(t)||t.length>0?!1:!0},n.isAlpha=function(t){return""===(t=l.forceString(t))?!1:/^[a-z]*$/gi.test(t)},n.isNumeric=function(t){return""===(t=l.forceString(t))?!1:/^[0-9]*$/g.test(t)},n.isAlphaNumeric=function(t){return""===(t=l.forceString(t))?!1:/^[0-9|a-z]*$/gi.test(t)},n.isSpecial=function(t){return""===(t=l.forceString(t))?!1:/^[^0-9|a-z]*$/gi.test(t)},n.isSpace=function(t){return/^[ \t]+$/g.test(t)},n.xs=function(t,r){var n,e,i,o,u;if(null==t&&(t=""),t=l.forceString(t),-1===(e=t.length-1))return"";for(r=l.forceFunction(r,function(t){return t}),o="",n=u=0;e>=0?e>=u:u>=e;n=e>=0?++u:--u)(i=r(t[n],n))&&(i===!0?o+=t[n]:l.isStringOrNumber(i)&&(o+=i));return o},n.copy=function(t,r,n){return r=l.forceNumber(r),""===(t=l.forceString(t))||Math.abs(r)>t.length?"":(r>0&&(r-=1),t.substr(r,l.forceNumber(n,t.length)))},n.replace=function(t,r,e,i){var o;return null==t&&(t=""),null==r&&(r=""),null==e&&(e=""),null==i&&(i="g"),!l.isStringOrNumber(t)||"string"!==(o=l["typeof"](r))&&"number"!==o&&"regexp"!==o?l.forceString(t):(l.notRegExp(r)&&(r=n.regEscape(r+""),r=new RegExp(r,i)),(t+"").replace(r,e))},n.trim=function(t){return n.replace(t,/^\s+|\s+$/g)},n.trimLeft=function(t){return n.replace(t,/^\s+/g)},n.trimRight=function(t){return n.replace(t,/\s+$/g)},n.oneSpace=function(t){return n.replace(t,/\s+/g," ")},n.oneSpaceAndTrim=function(t){return n.oneSpace(n.trim(t))},n.toCamel=function(t,r){var e;return t=l.forceString(t),r=l.forceString(r,"-"),e=new RegExp(n.regEscape(r)+"([a-z])","ig"),n.replace(t,e,function(t,r){return r.toUpperCase()})},n.unCamel=function(t,r){return t=l.forceString(t),r=l.forceString(r,"-"),n.replace(t,/([A-Z])/g,r+"$1").toLowerCase()},n.shuffle=function(t){return t=l.forceString(t),l.shuffleArray((t+"").split("")).join("")},n.find=function(t,r,e){var i,o;if(i=[],""===(t=l.forceString(t)))return i;if(e=l.forceString(e,"g"),l.isStringOrNumber(r))r=new RegExp(n.regEscape(r+""),e);else{if(!l.isRegExp(r))return i;r=new RegExp(r.source,e)}if(r.global)for(;o=r.exec(t);)i.push(o.index+1);else(o=r.exec(t))&&i.push(o.index+1);return i},n.count=function(t,r){return n.find(t,r).length},n.contains=function(t,r){return n.count(t,r)>0},n.between=function(t,r,e){var i,o;return l.allStringOrNumber(t,r,e)?(r=n.regEscape(r+""),e=n.regEscape(e+""),i=new RegExp(r+"(.+)"+e),(null!=(o=i.exec(t+""))?o[1]:void 0)||""):""},n.slice=function(t,r,n){return t=l.forceString(t),r=l.forceNumber(r||1),!1!==(r=l.positiveIndex(r,t.length))?(n=l.forceNumber(n),t.slice(r,r+n)):""},n.truncate=function(t,r,e){return t=l.forceString(t),r=l.forceNumber(r,t.length),t=n.slice(t,1,r),t+l.forceString(e)},n.pop=function(t,r){return t=l.forceString(t),r=l.forceNumber(r,1),t.slice(0,-Math.abs(r))},n.split=function(t,r){var e,i,o,u,s;if(t=n.oneSpaceAndTrim(t),i=[],t.length<1)return i;for(r=l.forceString(r," "),e=t.split(r[0]||""),u=0,s=e.length;s>u;u++)o=e[u],o.match(/^\s$/)||i.push(n.trim(o));return i},n.reverse=function(t){var r,n,e,i;if(null==t&&(t=""),t=l.forceString(t),(n=t.length-1)<1)return t;for(e="",r=i=n;0>=n?0>=i:i>=0;r=0>=n?++i:--i)e+=t[r];return e},n.upper=function(){var t,r;return r=arguments[0],t=2<=arguments.length?y.call(arguments,1):[],s.apply(null,[r,"toUpperCase"].concat(y.call(t)))},n.lower=function(){var t,r;return r=arguments[0],t=2<=arguments.length?y.call(arguments,1):[],s.apply(null,[r,"toLowerCase"].concat(y.call(t)))},n.insert=function(){var t,r,n,e,i,o;if(i=arguments[0],r=arguments[1],e=3<=arguments.length?y.call(arguments,2):[],""===(i=l.forceString(i))||""===(r=l.forceString(r)))return i;if(e=l.sortNoDupAndReverse(e,i.length),n=a(e)-1,0>n)return i;for(t=o=0;n>=0?n>=o:o>=n;t=n>=0?++o:--o)t=e[t],t>i.length?i+=r:i=i.substr(0,t)+r+i.substr(t);return i},n.removeRange=function(t,r,e){var i;return t=l.forceString(t),""===t||!1===(r=l.positiveIndex(r,t.length))||0>(e=l.forceNumber(e,1))?t:(i=r+e,n.xs(t,function(t,n){return r>n||n>=i?!0:void 0}))},n.removePos=function(){var t,r,e;return e=arguments[0],r=2<=arguments.length?y.call(arguments,1):[],""===(e=l.forceString(e))?"":(t=r.map(function(t){return l.positiveIndex(t,e.length)}),n.xs(e,function(r,n){return S.call(t,n)>=0?void 0:!0}))},n.remove=function(){var t,r,e,i,o;if(r=arguments[0],e=2<=arguments.length?y.call(arguments,1):[],null==r&&(r=""),""===(r=l.forceString(r))||e.length<1)return r;for(i=0,o=e.length;o>i;i++)t=e[i],r=n.replace(r,t);return r},n.startsWith=function(t,r){return""===(t=l.forceString(t))||""===(r=l.forceString(r))?!1:(r=new RegExp("^"+n.regEscape(r)),r.test(t))},n.endsWith=function(t,r){return""===(t=l.forceString(t))||""===(r=l.forceString(r))?!1:(r=new RegExp(n.regEscape(r)+"$"),r.test(t))},n.wrap=function(t,r){var e;return null==t&&(t=""),null==r&&(r=""),e=function(e){return n.create(t,e,r)},e.wrap=function(n,e){return null==n&&(n=""),null==e&&(e=""),t=l.forceString(n)+t,r+=l.forceString(e)},e},n.prototype.set=function(){return this.string=n.create.apply(this,arguments),this},n.prototype.sort=function(){return this.string=n.sort(this.string),this},n.prototype.random=function(t,r){return this.string=n.random(t,r),this},n.prototype.xs=function(t){return this.string=n.xs(this.string,t),this},n.prototype.times=function(t){return null==t&&(t=1),this.string=n.times(this.string,t),this},n.prototype.get=function(){var t,r,n,e;if(arguments.length>0){for(r="",n=0,e=arguments.length;e>n;n++)t=arguments[n],t=l.positiveIndex(t,this.length),t!==!1&&(r+=this.string[t]);return r}return this.string},n.prototype.copy=function(t,r){return n.copy(this.string,t,r)},n.prototype.empty=function(){return n.empty(this.string)},n.prototype.isAlpha=function(){return n.isAlpha(this.string)},n.prototype.isNumeric=function(){return n.isNumeric(this.string)},n.prototype.isAlphaNumeric=function(){return n.isAlphaNumeric(this.string)},n.prototype.isSpecial=function(){return n.isSpecial(this.string)},n.prototype.isSpace=function(){return n.isSpace(this.string)},n.prototype.push=function(){return this.string=this.string+n.create.apply(this,arguments),this},n.prototype.prepend=function(){return this.string=n.create.apply(this,arguments)+this.string,this},n.prototype.pop=function(t){return this.string=n.pop(this.string,t),this},n.prototype.insert=function(){var t,r;return r=arguments[0],t=2<=arguments.length?y.call(arguments,1):[],this.string=n.insert.apply(n,[this.string,r].concat(y.call(t))),this},n.prototype.trim=function(){return this.string=n.trim(this.string),this},n.prototype.trimLeft=function(){return this.string=n.trimLeft(this.string),this},n.prototype.trimRight=function(){return this.string=n.trimRight(this.string),this},n.prototype.oneSpace=function(){return this.string=n.oneSpace(this.string),this},n.prototype.oneSpaceAndTrim=function(){return this.string=n.oneSpaceAndTrim(this.string),this},n.prototype.find=function(t){return n.find(this.string,t)},n.prototype.count=function(t){return n.count(this.string,t)},n.prototype.contains=function(t){return n.contains(this.string,t)},n.prototype.between=function(t,r){return n.between(this.string,t,r)},n.prototype.slice=function(t,r){return this.string=n.slice(this.string,t,r),this},n.prototype.truncate=function(t,r){return this.string=n.truncate(this.string,t,r),this},n.prototype.remove=function(){var t;return t=1<=arguments.length?y.call(arguments,0):[],this.string=n.remove.apply(n,[this.string].concat(y.call(t))),this},n.prototype.removeRange=function(t,r){return this.string=n.removeRange(this.string,t,r),this},n.prototype.removePos=function(){var t;return t=1<=arguments.length?y.call(arguments,0):[],this.string=n.removePos.apply(n,[this.string].concat(y.call(t))),this},n.prototype.replace=function(t,r,e){return this.string=n.replace(this.string,t,r,e),this},n.prototype.reverse=function(){return this.string=n.reverse(this.string),this},n.prototype.upper=function(){var t;return t=1<=arguments.length?y.call(arguments,0):[],this.string=n.upper.apply(n,[this.string].concat(y.call(t))),this},n.prototype.lower=function(){var t;return t=1<=arguments.length?y.call(arguments,0):[],this.string=n.lower.apply(n,[this.string].concat(y.call(t))),this},n.prototype.shuffle=function(){return this.string=n.shuffle(this.string),this},n.prototype.toCamel=function(t){return this.string=n.toCamel(this.string,t),this},n.prototype.unCamel=function(t){return this.string=n.unCamel(this.string,t),this},n.prototype.startsWith=function(t){return n.startsWith(this.string,t)},n.prototype.endsWith=function(t){return n.endsWith(this.string,t)},n.prototype.setWrap=function(t,r){return l.isNull(this.wrapMethod)?this.wrapMethod=n.wrap(t,r):this.wrapMethod.wrap(t,r),this},n.prototype.removeWrap=function(){return this.wrapMethod=null,this},n.prototype.applyWrap=function(t,r){return this.string=this.setWrap(t,r).wrap,this.removeWrap(),this},n}(t),Object.defineProperty(n.prototype,"$",{get:function(){return this.get()}}),Object.defineProperty(n.prototype,"length",{get:function(){return this.string.length}}),Object.defineProperty(n.prototype,"wrap",{get:function(){return l.isNull(this.wrapMethod)?this.string:this.wrapMethod(this.string)}}),n.Types=i,n.Chars=t,n.crop=n.slice,n.prototype.crop=n.prototype.slice,n.prototype.append=n.prototype.push,"undefined"!=typeof window&&null!==window?window.Strings=n:module.exports=n}).call(this); |
974
words.js
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
"use strict"; | ||
var Strings, Words, applyToValidIndex, changeCase, delimiter, numbersFromArray, stringsFromArray, _, | ||
var Chars, LITERALS, Strings, Strings_, TYPES, Types, Words, Words_, breakIfEqual, createForce, instanceOf, mapStringToNumber, testValues, typeOf, _, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
__slice = [].slice, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
if (typeof window !== "undefined" && window !== null) { | ||
Strings = window.Strings; | ||
} else if (typeof module !== "undefined" && module !== null) { | ||
Strings = require('strings.js'); | ||
} | ||
instanceOf = function(type, value) { | ||
return value instanceof type; | ||
}; | ||
_ = Strings; | ||
typeOf = function(value, type) { | ||
if (type == null) { | ||
type = 'object'; | ||
} | ||
return typeof value === type; | ||
}; | ||
stringsFromArray = function(array) { | ||
var strings, value, _i, _len, _ref; | ||
strings = []; | ||
_ref = _.forceArray(array); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
value = _ref[_i]; | ||
if (_.isString(value)) { | ||
strings.push(value); | ||
LITERALS = { | ||
'Boolean': false, | ||
'String': '', | ||
'Object': {}, | ||
'Array': [], | ||
'Function': function() {}, | ||
'Number': (function() { | ||
var number; | ||
number = new Number; | ||
number["void"] = true; | ||
return number; | ||
})() | ||
}; | ||
TYPES = { | ||
'Undefined': function(value) { | ||
return value === void 0; | ||
}, | ||
'Null': function(value) { | ||
return value === null; | ||
}, | ||
'Function': function(value) { | ||
return typeOf(value, 'function'); | ||
}, | ||
'Boolean': function(value) { | ||
return typeOf(value, 'boolean'); | ||
}, | ||
'String': function(value) { | ||
return typeOf(value, 'string'); | ||
}, | ||
'Array': function(value) { | ||
return typeOf(value) && instanceOf(Array, value); | ||
}, | ||
'RegExp': function(value) { | ||
return typeOf(value) && instanceOf(RegExp, value); | ||
}, | ||
'Date': function(value) { | ||
return typeOf(value) && instanceOf(Date, value); | ||
}, | ||
'Number': function(value) { | ||
return typeOf(value, 'number') && (value === value) || (typeOf(value) && instanceOf(Number, value)); | ||
}, | ||
'Object': function(value) { | ||
return typeOf(value) && (value !== null) && !instanceOf(Boolean, value) && !instanceOf(Number, value) && !instanceOf(Array, value) && !instanceOf(RegExp, value) && !instanceOf(Date, value); | ||
}, | ||
'NaN': function(value) { | ||
return typeOf(value, 'number') && (value !== value); | ||
}, | ||
'Defined': function(value) { | ||
return value !== void 0; | ||
} | ||
}; | ||
TYPES.StringOrNumber = function(value) { | ||
return TYPES.String(value) || TYPES.Number(value); | ||
}; | ||
Types = _ = { | ||
parseIntBase: 10 | ||
}; | ||
createForce = function(type) { | ||
var convertType; | ||
convertType = function(value) { | ||
switch (type) { | ||
case 'Number': | ||
if ((_.isNumber(value = parseInt(value, _.parseIntBase))) && !value["void"]) { | ||
return value; | ||
} | ||
break; | ||
case 'String': | ||
if (_.isStringOrNumber(value)) { | ||
return value + ''; | ||
} | ||
break; | ||
default: | ||
if (Types['is' + type](value)) { | ||
return value; | ||
} | ||
} | ||
}; | ||
return function(value, replacement) { | ||
if ((value != null) && void 0 !== (value = convertType(value))) { | ||
return value; | ||
} | ||
if ((replacement != null) && void 0 !== (replacement = convertType(replacement))) { | ||
return replacement; | ||
} | ||
return LITERALS[type]; | ||
}; | ||
}; | ||
testValues = function(predicate, breakState, values) { | ||
var value, _i, _len; | ||
if (values == null) { | ||
values = []; | ||
} | ||
return strings; | ||
if (values.length < 1) { | ||
return predicate === TYPES.Undefined; | ||
} | ||
for (_i = 0, _len = values.length; _i < _len; _i++) { | ||
value = values[_i]; | ||
if (predicate(value) === breakState) { | ||
return breakState; | ||
} | ||
} | ||
return !breakState; | ||
}; | ||
numbersFromArray = function(array) { | ||
var numbers, value, _i, _len, _ref; | ||
numbers = []; | ||
_ref = _.forceArray(array); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
value = _ref[_i]; | ||
if (_.isNumber(value)) { | ||
numbers.push(value + 0); | ||
breakIfEqual = true; | ||
(function() { | ||
var name, predicate, _results; | ||
_results = []; | ||
for (name in TYPES) { | ||
predicate = TYPES[name]; | ||
_results.push((function(name, predicate) { | ||
Types['is' + name] = predicate; | ||
Types['not' + name] = function(value) { | ||
return !predicate(value); | ||
}; | ||
Types['has' + name] = function() { | ||
return testValues(predicate, breakIfEqual, arguments); | ||
}; | ||
Types['all' + name] = function() { | ||
return testValues(predicate, !breakIfEqual, arguments); | ||
}; | ||
if (name in LITERALS) { | ||
return Types['force' + name] = createForce(name); | ||
} | ||
})(name, predicate)); | ||
} | ||
return _results; | ||
})(); | ||
Types["typeof"] = function(value) { | ||
var name, predicate; | ||
for (name in TYPES) { | ||
predicate = TYPES[name]; | ||
if (predicate(value) === true) { | ||
return name.toLowerCase(); | ||
} | ||
} | ||
return numbers; | ||
}; | ||
changeCase = function(method, args) { | ||
var index, indices, pos, words, _i, _j, _k, _len, _len1, _ref, _results, _results1, _results2; | ||
words = stringsFromArray(args); | ||
indices = numbersFromArray(args); | ||
if (words.length > 0) { | ||
this.set(Strings[method].apply(Strings, [this.string].concat(__slice.call(words)))); | ||
mapStringToNumber = function(array) { | ||
var index, nr, value, _i, _len; | ||
if (_.notArray(array)) { | ||
return 0; | ||
} | ||
if (indices[0] === 0) { | ||
_results = []; | ||
for (_i = 0, _len = indices.length; _i < _len; _i++) { | ||
pos = indices[_i]; | ||
_results.push((function() { | ||
var _j, _ref, _results1; | ||
_results1 = []; | ||
for (index = _j = 0, _ref = this.count - 1; 0 <= _ref ? _j <= _ref : _j >= _ref; index = 0 <= _ref ? ++_j : --_j) { | ||
_results1.push(this.words[index] = Strings[method](this.words[index], pos)); | ||
} | ||
return _results1; | ||
}).call(this)); | ||
for (index = _i = 0, _len = array.length; _i < _len; index = ++_i) { | ||
value = array[index]; | ||
nr = _.forceNumber(value); | ||
if (nr["void"]) { | ||
return index; | ||
} | ||
return _results; | ||
} else { | ||
if (args.length < 1) { | ||
indices = (function() { | ||
_results1 = []; | ||
for (var _j = 0, _ref = this.count; 0 <= _ref ? _j <= _ref : _j >= _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); } | ||
return _results1; | ||
}).apply(this); | ||
array[index] = nr; | ||
} | ||
return array.length; | ||
}; | ||
_ = (function(_super) { | ||
__extends(_, _super); | ||
function _() { | ||
return _.__super__.constructor.apply(this, arguments); | ||
} | ||
_.inRange = function(nr, range) { | ||
if ((_.isNaN(nr = parseInt(nr, 10))) || (mapStringToNumber(range) < 2)) { | ||
return false; | ||
} | ||
_results2 = []; | ||
for (_k = 0, _len1 = indices.length; _k < _len1; _k++) { | ||
index = indices[_k]; | ||
index = _.positiveIndex(index, this.count); | ||
_results2.push(this.words[index] = Strings[method](this.words[index])); | ||
return (nr >= range[0]) && (nr <= range[1]); | ||
}; | ||
_.limitNumber = function(nr, range) { | ||
nr = _.forceNumber(nr, 0); | ||
if (mapStringToNumber(range) < 2) { | ||
return nr; | ||
} | ||
return _results2; | ||
if (nr < range[0]) { | ||
return range[0]; | ||
} | ||
if (nr > range[1]) { | ||
return range[1]; | ||
} | ||
return nr; | ||
}; | ||
_.randomNumber = function(min, max) { | ||
if (mapStringToNumber([min, max]) < 2) { | ||
return 0; | ||
} | ||
if (max < min) { | ||
return min; | ||
} | ||
max = (max - min) + 1; | ||
return Math.floor((Math.random() * max) + min); | ||
}; | ||
_.shuffleArray = function(array) { | ||
var i, length, rand, temp, _i; | ||
if (_.notArray(array) || array.length < 1) { | ||
return []; | ||
} | ||
length = array.length - 1; | ||
for (i = _i = length; length <= 0 ? _i <= 0 : _i >= 0; i = length <= 0 ? ++_i : --_i) { | ||
rand = _.randomNumber(0, i); | ||
temp = array[i]; | ||
array[i] = array[rand]; | ||
array[rand] = temp; | ||
} | ||
return array; | ||
}; | ||
_.positiveIndex = function(index, max) { | ||
if (0 === (index = _.forceNumber(index, 0))) { | ||
return false; | ||
} | ||
max = Math.abs(_.forceNumber(max)); | ||
if (Math.abs(index) <= max) { | ||
if (index > 0) { | ||
return index - 1; | ||
} | ||
return max + index; | ||
} | ||
return false; | ||
}; | ||
_.insertSort = function(array) { | ||
var current, index, length, prev, _i; | ||
length = array.length - 1; | ||
for (index = _i = 1; 1 <= length ? _i <= length : _i >= length; index = 1 <= length ? ++_i : --_i) { | ||
current = array[index]; | ||
prev = index - 1; | ||
while ((prev >= 0) && (array[prev] > current)) { | ||
array[prev + 1] = array[prev]; | ||
--prev; | ||
} | ||
array[+prev + 1] = current; | ||
} | ||
return array; | ||
}; | ||
_.noDupAndReverse = function(array) { | ||
var index, length, newArr, _i; | ||
length = array.length - 1; | ||
newArr = []; | ||
for (index = _i = length; length <= 0 ? _i <= 0 : _i >= 0; index = length <= 0 ? ++_i : --_i) { | ||
if (newArr[newArr.length - 1] !== array[index]) { | ||
newArr.push(array[index]); | ||
} | ||
} | ||
return newArr; | ||
}; | ||
_.sortNoDupAndReverse = function(array, maxLength) { | ||
var index, processed, value, _i, _len; | ||
processed = []; | ||
for (index = _i = 0, _len = array.length; _i < _len; index = ++_i) { | ||
value = array[index]; | ||
value = _.forceNumber(value); | ||
if (value["void"]) { | ||
continue; | ||
} | ||
if (value <= maxLength) { | ||
value = _.positiveIndex(value, maxLength); | ||
} | ||
processed.push(_.forceNumber(value, 0)); | ||
} | ||
return _.noDupAndReverse(_.insertSort(processed)); | ||
}; | ||
return _; | ||
})(Types); | ||
Chars = (function(_super) { | ||
__extends(Chars, _super); | ||
function Chars() { | ||
return Chars.__super__.constructor.apply(this, arguments); | ||
} | ||
}; | ||
applyToValidIndex = (function(_this) { | ||
return function(orgIndex, limit, callback) { | ||
Chars.ASCII_RANGE_UPPERCASE = [65, 90]; | ||
Chars.ASCII_RANGE_LOWERCASE = [97, 122]; | ||
Chars.ASCII_RANGE_NUMBERS = [48, 57]; | ||
Chars.ASCII_RANGE_SPECIAL_1 = [32, 47]; | ||
Chars.ASCII_RANGE_SPECIAL_2 = [58, 64]; | ||
Chars.ASCII_RANGE_SPECIAL_3 = [91, 96]; | ||
Chars.ASCII_RANGE_SPECIAL_4 = [123, 126]; | ||
Chars.ASCII_RANGE_ALL = [32, 126]; | ||
Chars.REGEXP_SPECIAL_CHARS = ['?', '\\', '[', ']', '(', ')', '*', '+', '.', '/', '|', '^', '$', '<', '>', '-', '&']; | ||
Chars.ascii = function(ordinal) { | ||
return String.fromCharCode(_.forceNumber(ordinal)); | ||
}; | ||
Chars.ordinal = function(char) { | ||
return _.forceNumber(_.forceString(char).charCodeAt(), 0); | ||
}; | ||
Chars.random = function(range) { | ||
var max, min; | ||
range = _.forceArray(range, Chars.ASCII_RANGE_ALL); | ||
min = _.limitNumber(range[0], range); | ||
max = _.limitNumber(range[1], range); | ||
return Chars.ascii(_.randomNumber(min, max)); | ||
}; | ||
return Chars; | ||
})(_); | ||
Strings_ = (function() { | ||
function Strings_() {} | ||
Strings_.changeCase = function() { | ||
var arg, args, caseMethod, pos, string, _i, _j, _len, _len1; | ||
string = arguments[0], caseMethod = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : []; | ||
if (string == null) { | ||
string = ''; | ||
} | ||
if ('' === (string = _.forceString(string))) { | ||
return string; | ||
} | ||
if ((args.length < 1) || args[0] === void 0) { | ||
return string[caseMethod](); | ||
} else if (_.isNumber(args[0])) { | ||
for (_i = 0, _len = args.length; _i < _len; _i++) { | ||
arg = args[_i]; | ||
pos = _.positiveIndex(arg, string.length); | ||
string = Strings.xs(string, function(char, index) { | ||
if (index === pos) { | ||
return char[caseMethod](); | ||
} | ||
return char; | ||
}); | ||
} | ||
} else if (_.isString(args[0])) { | ||
for (_j = 0, _len1 = args.length; _j < _len1; _j++) { | ||
arg = args[_j]; | ||
string = Strings.replace(string, arg, arg[caseMethod](), 'gi'); | ||
} | ||
} | ||
return string; | ||
}; | ||
return Strings_; | ||
})(); | ||
Strings = (function(_super) { | ||
__extends(Strings, _super); | ||
function Strings() { | ||
return Strings.__super__.constructor.apply(this, arguments); | ||
} | ||
Strings.create = function() { | ||
var arg, string, _i, _len; | ||
string = ''; | ||
for (_i = 0, _len = arguments.length; _i < _len; _i++) { | ||
arg = arguments[_i]; | ||
string += _.forceString(arg); | ||
} | ||
return string; | ||
}; | ||
Strings.get = function() { | ||
var argsLength, length, pos, positions, result, string, _i; | ||
string = arguments[0], positions = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
if (arguments.length < 2) { | ||
return ''; | ||
} | ||
string = _.forceString(string); | ||
length = string.length; | ||
result = ''; | ||
argsLength = arguments.length; | ||
for (pos = _i = 1; 1 <= argsLength ? _i <= argsLength : _i >= argsLength; pos = 1 <= argsLength ? ++_i : --_i) { | ||
pos = _.positiveIndex(arguments[pos], length); | ||
if (pos !== false) { | ||
result += string[pos]; | ||
} | ||
} | ||
return result; | ||
}; | ||
Strings.sort = function(string) { | ||
string = _.forceString(string).trim().split(''); | ||
return _.insertSort(string).join(''); | ||
}; | ||
Strings.random = function(amount, charSet) { | ||
var i, string, _i; | ||
amount = _.forceNumber(amount, 1); | ||
string = ''; | ||
for (i = _i = 1; 1 <= amount ? _i <= amount : _i >= amount; i = 1 <= amount ? ++_i : --_i) { | ||
string += Chars.random(charSet); | ||
} | ||
return string; | ||
}; | ||
Strings.times = function(string, amount) { | ||
var multi; | ||
if ('' === (string = _.forceString(string))) { | ||
return ''; | ||
} | ||
amount = _.forceNumber(amount, 1); | ||
multi = ''; | ||
while (amount-- > 0) { | ||
multi += string; | ||
} | ||
return multi; | ||
}; | ||
Strings.regEscape = function(string) { | ||
if ('' === (string = _.forceString(string))) { | ||
return string; | ||
} | ||
return Strings.xs(string, function(char) { | ||
if (__indexOf.call(Chars.REGEXP_SPECIAL_CHARS, char) >= 0) { | ||
return '\\' + char; | ||
} | ||
return true; | ||
}); | ||
}; | ||
Strings.empty = function(string) { | ||
if (_.notString(string) || (string.length > 0)) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
Strings.isAlpha = function(string) { | ||
if ('' === (string = _.forceString(string))) { | ||
return false; | ||
} | ||
return /^[a-z]*$/ig.test(string); | ||
}; | ||
Strings.isNumeric = function(string) { | ||
if ('' === (string = _.forceString(string))) { | ||
return false; | ||
} | ||
return /^[0-9]*$/g.test(string); | ||
}; | ||
Strings.isAlphaNumeric = function(string) { | ||
if ('' === (string = _.forceString(string))) { | ||
return false; | ||
} | ||
return /^[0-9|a-z]*$/ig.test(string); | ||
}; | ||
Strings.isSpecial = function(string) { | ||
if ('' === (string = _.forceString(string))) { | ||
return false; | ||
} | ||
return /^[^0-9|a-z]*$/ig.test(string); | ||
}; | ||
Strings.isSpace = function(string) { | ||
return /^[ \t]+$/g.test(string); | ||
}; | ||
Strings.xs = function(string, callback) { | ||
var index, length, response, result, _i; | ||
if (string == null) { | ||
string = ''; | ||
} | ||
string = _.forceString(string); | ||
if (-1 === (length = string.length - 1)) { | ||
return ''; | ||
} | ||
callback = _.forceFunction(callback, function(char) { | ||
return char; | ||
}); | ||
result = ''; | ||
for (index = _i = 0; 0 <= length ? _i <= length : _i >= length; index = 0 <= length ? ++_i : --_i) { | ||
if (response = callback(string[index], index)) { | ||
if (response === true) { | ||
result += string[index]; | ||
} else if (_.isStringOrNumber(response)) { | ||
result += response; | ||
} | ||
} | ||
} | ||
return result; | ||
}; | ||
Strings.copy = function(string, offset, amount) { | ||
offset = _.forceNumber(offset); | ||
if (('' === (string = _.forceString(string))) || (Math.abs(offset) > string.length)) { | ||
return ''; | ||
} | ||
if (offset > 0) { | ||
offset -= 1; | ||
} | ||
return string.substr(offset, _.forceNumber(amount, string.length)); | ||
}; | ||
Strings.replace = function(string, toReplace, replacement, flags) { | ||
var _ref; | ||
if (string == null) { | ||
string = ''; | ||
} | ||
if (toReplace == null) { | ||
toReplace = ''; | ||
} | ||
if (replacement == null) { | ||
replacement = ''; | ||
} | ||
if (flags == null) { | ||
flags = 'g'; | ||
} | ||
if (!(_.isStringOrNumber(string) && ((_ref = _["typeof"](toReplace)) === 'string' || _ref === 'number' || _ref === 'regexp'))) { | ||
return _.forceString(string); | ||
} | ||
if (_.notRegExp(toReplace)) { | ||
toReplace = Strings.regEscape(toReplace + ''); | ||
toReplace = new RegExp(toReplace, flags); | ||
} | ||
return (string + '').replace(toReplace, replacement); | ||
}; | ||
Strings.trim = function(string) { | ||
return Strings.replace(string, /^\s+|\s+$/g); | ||
}; | ||
Strings.trimLeft = function(string) { | ||
return Strings.replace(string, /^\s+/g); | ||
}; | ||
Strings.trimRight = function(string) { | ||
return Strings.replace(string, /\s+$/g); | ||
}; | ||
Strings.oneSpace = function(string) { | ||
return Strings.replace(string, /\s+/g, ' '); | ||
}; | ||
Strings.oneSpaceAndTrim = function(string) { | ||
return Strings.oneSpace(Strings.trim(string)); | ||
}; | ||
Strings.toCamel = function(string, char) { | ||
var match; | ||
string = _.forceString(string); | ||
char = _.forceString(char, '-'); | ||
match = new RegExp(Strings.regEscape(char) + '([a-z])', 'ig'); | ||
return Strings.replace(string, match, function(all, found) { | ||
return found.toUpperCase(); | ||
}); | ||
}; | ||
Strings.unCamel = function(string, insertion) { | ||
string = _.forceString(string); | ||
insertion = _.forceString(insertion, '-'); | ||
return Strings.replace(string, /([A-Z])/g, insertion + '$1').toLowerCase(); | ||
}; | ||
Strings.shuffle = function(string) { | ||
string = _.forceString(string); | ||
return _.shuffleArray((string + '').split('')).join(''); | ||
}; | ||
Strings.find = function(string, toFind, flags) { | ||
var indices, result; | ||
indices = []; | ||
if ('' === (string = _.forceString(string))) { | ||
return indices; | ||
} | ||
flags = _.forceString(flags, 'g'); | ||
if (_.isStringOrNumber(toFind)) { | ||
toFind = new RegExp(Strings.regEscape(toFind + ''), flags); | ||
} else if (_.isRegExp(toFind)) { | ||
toFind = new RegExp(toFind.source, flags); | ||
} else { | ||
return indices; | ||
} | ||
if (toFind.global) { | ||
while (result = toFind.exec(string)) { | ||
indices.push(result.index + 1); | ||
} | ||
} else { | ||
if (result = toFind.exec(string)) { | ||
indices.push(result.index + 1); | ||
} | ||
} | ||
return indices; | ||
}; | ||
Strings.count = function(string, toFind) { | ||
return Strings.find(string, toFind).length; | ||
}; | ||
Strings.contains = function(string, substring) { | ||
return Strings.count(string, substring) > 0; | ||
}; | ||
Strings.between = function(string, before, after) { | ||
var reg, _ref; | ||
if (!_.allStringOrNumber(string, before, after)) { | ||
return ''; | ||
} | ||
before = Strings.regEscape(before + ''); | ||
after = Strings.regEscape(after + ''); | ||
reg = new RegExp(before + '(.+)' + after); | ||
return ((_ref = reg.exec(string + '')) != null ? _ref[1] : void 0) || ''; | ||
}; | ||
Strings.slice = function(string, start, size) { | ||
string = _.forceString(string); | ||
start = _.forceNumber(start || 1); | ||
if (false !== (start = _.positiveIndex(start, string.length))) { | ||
size = _.forceNumber(size); | ||
return string.slice(start, start + size); | ||
} | ||
return ''; | ||
}; | ||
Strings.truncate = function(string, length, appendix) { | ||
string = _.forceString(string); | ||
length = _.forceNumber(length, string.length); | ||
string = Strings.slice(string, 1, length); | ||
return string + _.forceString(appendix); | ||
}; | ||
Strings.pop = function(string, amount) { | ||
string = _.forceString(string); | ||
amount = _.forceNumber(amount, 1); | ||
return string.slice(0, -Math.abs(amount)); | ||
}; | ||
Strings.split = function(string, delimiter) { | ||
var array, result, word, _i, _len; | ||
string = Strings.oneSpaceAndTrim(string); | ||
result = []; | ||
if (string.length < 1) { | ||
return result; | ||
} | ||
delimiter = _.forceString(delimiter, ' '); | ||
array = string.split(delimiter[0] || ''); | ||
for (_i = 0, _len = array.length; _i < _len; _i++) { | ||
word = array[_i]; | ||
if (word.match(/^\s$/)) { | ||
continue; | ||
} | ||
result.push(Strings.trim(word)); | ||
} | ||
return result; | ||
}; | ||
Strings.reverse = function(string) { | ||
var ch, length, reversed, _i; | ||
if (string == null) { | ||
string = ''; | ||
} | ||
string = _.forceString(string); | ||
if ((length = string.length - 1) < 1) { | ||
return string; | ||
} | ||
reversed = ''; | ||
for (ch = _i = length; length <= 0 ? _i <= 0 : _i >= 0; ch = length <= 0 ? ++_i : --_i) { | ||
reversed += string[ch]; | ||
} | ||
return reversed; | ||
}; | ||
Strings.upper = function() { | ||
var args, string; | ||
string = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
return Strings_.changeCase.apply(Strings_, [string, 'toUpperCase'].concat(__slice.call(args))); | ||
}; | ||
Strings.lower = function() { | ||
var args, string; | ||
string = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
return Strings_.changeCase.apply(Strings_, [string, 'toLowerCase'].concat(__slice.call(args))); | ||
}; | ||
Strings.insert = function() { | ||
var index, insertion, posCount, positions, string, _i; | ||
string = arguments[0], insertion = arguments[1], positions = 3 <= arguments.length ? __slice.call(arguments, 2) : []; | ||
if (('' === (string = _.forceString(string))) || ('' === (insertion = _.forceString(insertion)))) { | ||
return string; | ||
} | ||
positions = _.sortNoDupAndReverse(positions, string.length); | ||
posCount = mapStringToNumber(positions) - 1; | ||
if (0 > posCount) { | ||
return string; | ||
} | ||
for (index = _i = 0; 0 <= posCount ? _i <= posCount : _i >= posCount; index = 0 <= posCount ? ++_i : --_i) { | ||
index = positions[index]; | ||
if (index > string.length) { | ||
string = string + insertion; | ||
continue; | ||
} | ||
string = string.substr(0, index) + insertion + string.substr(index); | ||
} | ||
return string; | ||
}; | ||
Strings.removeRange = function(string, offset, amount) { | ||
var endpoint; | ||
string = _.forceString(string); | ||
if ((string === '') || (false === (offset = _.positiveIndex(offset, string.length))) || (0 > (amount = _.forceNumber(amount, 1)))) { | ||
return string; | ||
} | ||
endpoint = offset + amount; | ||
return Strings.xs(string, function(char, index) { | ||
if ((index < offset) || (index >= endpoint)) { | ||
return true; | ||
} | ||
}); | ||
}; | ||
Strings.removePos = function() { | ||
var pos, positions, string; | ||
string = arguments[0], positions = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
if ('' === (string = _.forceString(string))) { | ||
return ''; | ||
} | ||
pos = positions.map(function(value, index) { | ||
return _.positiveIndex(value, string.length); | ||
}); | ||
return Strings.xs(string, function(char, index) { | ||
if (!(__indexOf.call(pos, index) >= 0)) { | ||
return true; | ||
} | ||
}); | ||
}; | ||
Strings.remove = function() { | ||
var remove, string, toRemove, _i, _len; | ||
string = arguments[0], toRemove = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
if (string == null) { | ||
string = ''; | ||
} | ||
if (('' === (string = _.forceString(string))) || (toRemove.length < 1)) { | ||
return string; | ||
} | ||
for (_i = 0, _len = toRemove.length; _i < _len; _i++) { | ||
remove = toRemove[_i]; | ||
string = Strings.replace(string, remove); | ||
} | ||
return string; | ||
}; | ||
Strings.startsWith = function(string, start) { | ||
if (('' === (string = _.forceString(string))) || ('' === (start = _.forceString(start)))) { | ||
return false; | ||
} | ||
start = new RegExp('^' + Strings.regEscape(start)); | ||
return start.test(string); | ||
}; | ||
Strings.endsWith = function(string, ending) { | ||
if (('' === (string = _.forceString(string))) || ('' === (ending = _.forceString(ending)))) { | ||
return false; | ||
} | ||
ending = new RegExp(Strings.regEscape(ending) + '$'); | ||
return ending.test(string); | ||
}; | ||
Strings.wrap = function(prepend, append) { | ||
var wrapper; | ||
if (prepend == null) { | ||
prepend = ''; | ||
} | ||
if (append == null) { | ||
append = ''; | ||
} | ||
wrapper = function(string) { | ||
return Strings.create(prepend, string, append); | ||
}; | ||
wrapper.wrap = function(outerPrepend, outerAppend) { | ||
if (outerPrepend == null) { | ||
outerPrepend = ''; | ||
} | ||
if (outerAppend == null) { | ||
outerAppend = ''; | ||
} | ||
prepend = _.forceString(outerPrepend) + prepend; | ||
return append += _.forceString(outerAppend); | ||
}; | ||
return wrapper; | ||
}; | ||
return Strings; | ||
})(Chars); | ||
Strings.Types = Types; | ||
Strings.Chars = Chars; | ||
Strings.crop = Strings.slice; | ||
Words_ = (function() { | ||
function Words_() {} | ||
Words_.delimiter = ' '; | ||
Words_.stringsFromArray = function(array) { | ||
var strings, value, _i, _len, _ref; | ||
strings = []; | ||
_ref = _.forceArray(array); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
value = _ref[_i]; | ||
if (_.isString(value)) { | ||
strings.push(value); | ||
} | ||
} | ||
return strings; | ||
}; | ||
Words_.numbersFromArray = function(array) { | ||
var numbers, value, _i, _len, _ref; | ||
numbers = []; | ||
_ref = _.forceArray(array); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
value = _ref[_i]; | ||
if (_.isNumber(value)) { | ||
numbers.push(value + 0); | ||
} | ||
} | ||
return numbers; | ||
}; | ||
Words_.changeCase = function(method, args) { | ||
var index, indices, pos, words, _i, _j, _k, _len, _len1, _ref, _results, _results1, _results2; | ||
words = Words_.stringsFromArray(args); | ||
indices = Words_.numbersFromArray(args); | ||
if (words.length > 0) { | ||
this.set(Strings[method].apply(Strings, [this.string].concat(__slice.call(words)))); | ||
} | ||
if (indices[0] === 0) { | ||
_results = []; | ||
for (_i = 0, _len = indices.length; _i < _len; _i++) { | ||
pos = indices[_i]; | ||
_results.push((function() { | ||
var _j, _ref, _results1; | ||
_results1 = []; | ||
for (index = _j = 0, _ref = this.count - 1; 0 <= _ref ? _j <= _ref : _j >= _ref; index = 0 <= _ref ? ++_j : --_j) { | ||
_results1.push(this.words[index] = Strings[method](this.words[index], pos)); | ||
} | ||
return _results1; | ||
}).call(this)); | ||
} | ||
return _results; | ||
} else { | ||
if (args.length < 1) { | ||
indices = (function() { | ||
_results1 = []; | ||
for (var _j = 0, _ref = this.count; 0 <= _ref ? _j <= _ref : _j >= _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); } | ||
return _results1; | ||
}).apply(this); | ||
} | ||
_results2 = []; | ||
for (_k = 0, _len1 = indices.length; _k < _len1; _k++) { | ||
index = indices[_k]; | ||
index = _.positiveIndex(index, this.count); | ||
_results2.push(this.words[index] = Strings[method](this.words[index])); | ||
} | ||
return _results2; | ||
} | ||
}; | ||
Words_.applyToValidIndex = function(orgIndex, limit, callback) { | ||
var index; | ||
@@ -89,6 +906,7 @@ if (false !== (index = _.positiveIndex(orgIndex, limit))) { | ||
}; | ||
})(this); | ||
delimiter = ' '; | ||
return Words_; | ||
})(); | ||
Words = (function(_super) { | ||
@@ -109,3 +927,3 @@ __extends(Words, _super); | ||
arg = arguments[_i]; | ||
_ref = Strings.split(Strings.create(arg), delimiter); | ||
_ref = Strings.split(Strings.create(arg), Words_.delimiter); | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
@@ -122,3 +940,3 @@ str = _ref[_j]; | ||
if (arguments.length < 1) { | ||
return this.words.join(delimiter); | ||
return this.words.join(Words_.delimiter); | ||
} | ||
@@ -130,3 +948,3 @@ string = ''; | ||
if (index !== false) { | ||
string += this.words[index] + delimiter; | ||
string += this.words[index] + Words_.delimiter; | ||
} | ||
@@ -178,3 +996,3 @@ } | ||
Words.prototype.upper = function() { | ||
changeCase.call(this, 'upper', Array.prototype.slice.call(arguments)); | ||
Words_.changeCase.call(this, 'upper', Array.prototype.slice.call(arguments)); | ||
return this; | ||
@@ -184,3 +1002,3 @@ }; | ||
Words.prototype.lower = function() { | ||
changeCase.call(this, 'lower', Array.prototype.slice.call(arguments)); | ||
Words_.changeCase.call(this, 'lower', Array.prototype.slice.call(arguments)); | ||
return this; | ||
@@ -198,3 +1016,3 @@ }; | ||
arg = arguments[_i]; | ||
applyToValidIndex(arg, this.count, (function(_this) { | ||
Words_.applyToValidIndex(arg, this.count, (function(_this) { | ||
return function(index) { | ||
@@ -237,3 +1055,3 @@ return _this.words[index] = Strings.reverse(_this.words[index]); | ||
arg = arguments[_j]; | ||
applyToValidIndex(arg, this.count, (function(_this) { | ||
Words_.applyToValidIndex(arg, this.count, (function(_this) { | ||
return function(index) { | ||
@@ -357,3 +1175,3 @@ return _this.words[index] = Strings.shuffle(_this.words[index]); | ||
if (_.isNumber(selection)) { | ||
applyToValidIndex(selection, this.count, (function(_this) { | ||
Words_.applyToValidIndex(selection, this.count, (function(_this) { | ||
return function(index) { | ||
@@ -438,14 +1256,12 @@ return _this.words.splice(index, 1, replacement); | ||
Words.Types = Strings.Types; | ||
Words.Types = Types; | ||
Words.Chars = Strings.Chars; | ||
Words.Chars = Chars; | ||
if (typeof window !== "undefined" && window !== null) { | ||
return window.Words = Words; | ||
window.Words = Words; | ||
} else { | ||
module.exports = Words; | ||
} | ||
if (typeof module !== "undefined" && module !== null) { | ||
return module.exports = Words; | ||
} | ||
}).call(this); |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var t,r,n,e,o,i,s,u,h=[].slice,f={}.hasOwnProperty,p=function(t,r){function n(){this.constructor=t}for(var e in r)f.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t};return"undefined"!=typeof window&&null!==window?t=window.Strings:"undefined"!=typeof module&&null!==module&&(t=require("strings.js")),u=t,s=function(t){var r,n,e,o,i;for(r=[],i=u.forceArray(t),e=0,o=i.length;o>e;e++)n=i[e],u.isString(n)&&r.push(n);return r},i=function(t){var r,n,e,o,i;for(r=[],i=u.forceArray(t),e=0,o=i.length;o>e;e++)n=i[e],u.isNumber(n)&&r.push(n+0);return r},e=function(r,n){var e,o,f,p,c,l,a,g,d,y,m;if(p=s(n),o=i(n),p.length>0&&this.set(t[r].apply(t,[this.string].concat(h.call(p)))),0===o[0]){for(d=[],c=0,a=o.length;a>c;c++)f=o[c],d.push(function(){var n,o,i;for(i=[],e=n=0,o=this.count-1;o>=0?o>=n:n>=o;e=o>=0?++n:--n)i.push(this.words[e]=t[r](this.words[e],f));return i}.call(this));return d}for(n.length<1&&(o=function(){y=[];for(var t=0,r=this.count;r>=0?r>=t:t>=r;r>=0?t++:t--)y.push(t);return y}.apply(this)),m=[],l=0,g=o.length;g>l;l++)e=o[l],e=u.positiveIndex(e,this.count),m.push(this.words[e]=t[r](this.words[e]));return m},n=function(){return function(t,r,n){var e;return!1!==(e=u.positiveIndex(t,r))?n(e):void 0}}(this),o=" ",r=function(r){function i(){this.set.apply(this,arguments)}return p(i,r),i.prototype.set=function(){var r,n,e,i,s,u,h;if(this.words=[],arguments.length<1)return this;for(e=0,s=arguments.length;s>e;e++)for(r=arguments[e],h=t.split(t.create(r),o),i=0,u=h.length;u>i;i++)n=h[i],this.words.push(n);return this},i.prototype.get=function(){var r,n,e,i;if(arguments.length<1)return this.words.join(o);for(n="",e=0,i=arguments.length;i>e;e++)r=arguments[e],r=u.positiveIndex(r,this.count),r!==!1&&(n+=this.words[r]+o);return t.trim(n)},i.prototype.xs=function(t){var r,n,e,o,i,s,h;if(null==t&&(t=function(){return!0}),u.notFunction(t)||this.count<1)return this;for(e=[],h=this.words,r=i=0,s=h.length;s>i;r=++i)o=h[r],(n=t(o,r))&&(n===!0?e.push(o):u.isStringOrNumber(n)&&e.push(n+""));return this.words=e,this},i.prototype.find=function(t){var r;return r=[],""!==(t=u.forceString(t))&&this.xs(function(n,e){return n===t&&r.push(e+1),!0}),r},i.prototype.upper=function(){return e.call(this,"upper",Array.prototype.slice.call(arguments)),this},i.prototype.lower=function(){return e.call(this,"lower",Array.prototype.slice.call(arguments)),this},i.prototype.reverse=function(){var r,e,o;if(0===(null!=arguments?arguments[0]:void 0))this.xs(function(r){return t.reverse(r)});else if(arguments.length>0)for(e=0,o=arguments.length;o>e;e++)r=arguments[e],n(r,this.count,function(r){return function(n){return r.words[n]=t.reverse(r.words[n])}}(this));else this.xs(function(t){return function(r,n){return t.get(t.count-n)}}(this));return this},i.prototype.shuffle=function(r){var e,o,i,s,h;if(null!=r)if(u.isString(r))for(o=0,s=arguments.length;s>o;o++)e=arguments[o],this.xs(function(){return function(r){return r===e?t.shuffle(r):!0}}(this));else if(0===r)this.xs(function(r){return t.shuffle(r)});else for(i=0,h=arguments.length;h>i;i++)e=arguments[i],n(e,this.count,function(r){return function(n){return r.words[n]=t.shuffle(r.words[n])}}(this));else this.words=u.shuffleArray(this.words);return this},i.prototype.clear=function(){return this.words=[],this},i.prototype.remove=function(){var t,r,n,e,o,s,h;if(arguments.length<1)return this;for(r=[],e=0,s=arguments.length;s>e;e++)t=arguments[e],u.isString(t)?r.unshift(t):u.isNumber(t)&&r.push(i.positiveIndex(t,this.count));for(r=u.noDupAndReverse(u.insertSort(r)),n=o=0,h=r.length;h>o;n=++o)t=r[n],u.isNumber(t)?this.xs(function(){return function(r,n){return n!==t?!0:void 0}}(this)):u.isString(t)&&this.xs(function(r){return r!==t?!0:void 0});return this},i.prototype.pop=function(t){var r,n;for(t=Math.abs(u.forceNumber(t,1)),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.pop();return this},i.prototype.push=function(){var r,n,e;for(n=0,e=arguments.length;e>n;n++)r=arguments[n],""!==(r=u.forceString(r))&&this.words.push(t.trim(r));return this},i.prototype.shift=function(t){var r,n;for(t=u.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.shift();return this},i.prototype.prepend=function(){var r,n,e,o;for(n=0,e=0,o=arguments.length;o>e;e++)r=arguments[e],""!==(r=u.forceString(r))&&(this.words.splice(n,0,t.trim(r)),n++);return this},i.prototype.insert=function(){var r,n,e,o,i,s;for(r=arguments[0],o=2<=arguments.length?h.call(arguments,1):[],r=u.positiveIndex(r,this.count),n=0,i=0,s=o.length;s>i;i++)e=o[i],""!==(e=u.forceString(e))&&(this.words.splice(r+n,0,t.trim(e)),n++);return this},i.prototype.replace=function(r,e){return null==e&&(e=""),""===(e=t.trim(e))?this:(u.isNumber(r)?n(r,this.count,function(t){return function(r){return t.words.splice(r,1,e)}}(this)):this.xs(function(t){return t===r?e:!0}),this)},i.prototype.sort=function(){return u.insertSort(this.words),this},i.prototype.startsWith=function(t){var r;return""===(t=u.forceString(t))?!1:(r=!0,t=new i(t),t.xs(function(t){return function(n,e){return n!==t.words[e]?r=!1:void 0}}(this)),r)},i.prototype.endsWith=function(t){var r,n,e,o,s;if(""===(t=u.forceString(t)))return!1;for(e=!0,r=1,t=new i(t),n=o=s=t.count;1>=s?1>=o:o>=1;n=1>=s?++o:--o)t.get(n)!==this.words[this.count-r++]&&(e=!1);return e},i}(t),Object.defineProperty(r.prototype,"$",{get:function(){return this.get()}}),Object.defineProperty(r.prototype,"string",{get:function(){return this.get()}}),Object.defineProperty(r.prototype,"count",{get:function(){return this.words.length}}),r.prototype.unshift=r.prototype.prepend,r.Strings=t,r.Types=t.Types,r.Chars=t.Chars,"undefined"!=typeof window&&null!==window?window.Words=r:"undefined"!=typeof module&&null!==module?module.exports=r:void 0}).call(this); | ||
(function(){"use strict";var r,n,t,e,u,i,o,s,c,f,a,g,l,p,h,m={}.hasOwnProperty,d=function(r,n){function t(){this.constructor=r}for(var e in n)m.call(n,e)&&(r[e]=n[e]);return t.prototype=n.prototype,r.prototype=new t,r.__super__=n.prototype,r},v=[].slice,S=[].indexOf||function(r){for(var n=0,t=this.length;t>n;n++)if(n in this&&this[n]===r)return n;return-1};a=function(r,n){return n instanceof r},p=function(r,n){return null==n&&(n="object"),typeof r===n},n={Boolean:!1,String:"",Object:{},Array:[],Function:function(){},Number:function(){var r;return r=new Number,r["void"]=!0,r}()},u={Undefined:function(r){return void 0===r},Null:function(r){return null===r},Function:function(r){return p(r,"function")},Boolean:function(r){return p(r,"boolean")},String:function(r){return p(r,"string")},Array:function(r){return p(r)&&a(Array,r)},RegExp:function(r){return p(r)&&a(RegExp,r)},Date:function(r){return p(r)&&a(Date,r)},Number:function(r){return p(r,"number")&&r===r||p(r)&&a(Number,r)},Object:function(r){return!(!p(r)||null===r||a(Boolean,r)||a(Number,r)||a(Array,r)||a(RegExp,r)||a(Date,r))},NaN:function(r){return p(r,"number")&&r!==r},Defined:function(r){return void 0!==r}},u.StringOrNumber=function(r){return u.String(r)||u.Number(r)},i=h={parseIntBase:10},f=function(r){var t;return t=function(n){switch(r){case"Number":if(h.isNumber(n=parseInt(n,h.parseIntBase))&&!n["void"])return n;break;case"String":if(h.isStringOrNumber(n))return n+"";break;default:if(i["is"+r](n))return n}},function(e,u){return null!=e&&void 0!==(e=t(e))?e:null!=u&&void 0!==(u=t(u))?u:n[r]}},l=function(r,n,t){var e,i,o;if(null==t&&(t=[]),t.length<1)return r===u.Undefined;for(i=0,o=t.length;o>i;i++)if(e=t[i],r(e)===n)return n;return!n},c=!0,function(){var r,t,e;e=[];for(r in u)t=u[r],e.push(function(r,t){return i["is"+r]=t,i["not"+r]=function(r){return!t(r)},i["has"+r]=function(){return l(t,c,arguments)},i["all"+r]=function(){return l(t,!c,arguments)},r in n?i["force"+r]=f(r):void 0}(r,t));return e}(),i["typeof"]=function(r){var n,t;for(n in u)if(t=u[n],t(r)===!0)return n.toLowerCase()},g=function(r){var n,t,e,u,i;if(h.notArray(r))return 0;for(n=u=0,i=r.length;i>u;n=++u){if(e=r[n],t=h.forceNumber(e),t["void"])return n;r[n]=t}return r.length},h=function(r){function n(){return n.__super__.constructor.apply(this,arguments)}return d(n,r),n.inRange=function(r,t){return n.isNaN(r=parseInt(r,10))||g(t)<2?!1:r>=t[0]&&r<=t[1]},n.limitNumber=function(r,t){return r=n.forceNumber(r,0),g(t)<2?r:r<t[0]?t[0]:r>t[1]?t[1]:r},n.randomNumber=function(r,n){return g([r,n])<2?0:r>n?r:(n=n-r+1,Math.floor(Math.random()*n+r))},n.shuffleArray=function(r){var t,e,u,i,o;if(n.notArray(r)||r.length<1)return[];for(e=r.length-1,t=o=e;0>=e?0>=o:o>=0;t=0>=e?++o:--o)u=n.randomNumber(0,t),i=r[t],r[t]=r[u],r[u]=i;return r},n.positiveIndex=function(r,t){return 0===(r=n.forceNumber(r,0))?!1:(t=Math.abs(n.forceNumber(t)),Math.abs(r)<=t?r>0?r-1:t+r:!1)},n.insertSort=function(r){var n,t,e,u,i;for(e=r.length-1,t=i=1;e>=1?e>=i:i>=e;t=e>=1?++i:--i){for(n=r[t],u=t-1;u>=0&&r[u]>n;)r[u+1]=r[u],--u;r[+u+1]=n}return r},n.noDupAndReverse=function(r){var n,t,e,u;for(t=r.length-1,e=[],n=u=t;0>=t?0>=u:u>=0;n=0>=t?++u:--u)e[e.length-1]!==r[n]&&e.push(r[n]);return e},n.sortNoDupAndReverse=function(r,t){var e,u,i,o,s;for(u=[],e=o=0,s=r.length;s>o;e=++o)i=r[e],i=n.forceNumber(i),i["void"]||(t>=i&&(i=n.positiveIndex(i,t)),u.push(n.forceNumber(i,0)));return n.noDupAndReverse(n.insertSort(u))},n}(i),r=function(r){function n(){return n.__super__.constructor.apply(this,arguments)}return d(n,r),n.ASCII_RANGE_UPPERCASE=[65,90],n.ASCII_RANGE_LOWERCASE=[97,122],n.ASCII_RANGE_NUMBERS=[48,57],n.ASCII_RANGE_SPECIAL_1=[32,47],n.ASCII_RANGE_SPECIAL_2=[58,64],n.ASCII_RANGE_SPECIAL_3=[91,96],n.ASCII_RANGE_SPECIAL_4=[123,126],n.ASCII_RANGE_ALL=[32,126],n.REGEXP_SPECIAL_CHARS=["?","\\","[","]","(",")","*","+",".","/","|","^","$","<",">","-","&"],n.ascii=function(r){return String.fromCharCode(h.forceNumber(r))},n.ordinal=function(r){return h.forceNumber(h.forceString(r).charCodeAt(),0)},n.random=function(r){var t,e;return r=h.forceArray(r,n.ASCII_RANGE_ALL),e=h.limitNumber(r[0],r),t=h.limitNumber(r[1],r),n.ascii(h.randomNumber(e,t))},n}(h),e=function(){function r(){}return r.changeCase=function(){var r,n,e,u,i,o,s,c,f;if(i=arguments[0],e=arguments[1],n=3<=arguments.length?v.call(arguments,2):[],null==i&&(i=""),""===(i=h.forceString(i)))return i;if(n.length<1||void 0===n[0])return i[e]();if(h.isNumber(n[0]))for(o=0,c=n.length;c>o;o++)r=n[o],u=h.positiveIndex(r,i.length),i=t.xs(i,function(r,n){return n===u?r[e]():r});else if(h.isString(n[0]))for(s=0,f=n.length;f>s;s++)r=n[s],i=t.replace(i,r,r[e](),"gi");return i},r}(),t=function(n){function t(){return t.__super__.constructor.apply(this,arguments)}return d(t,n),t.create=function(){var r,n,t,e;for(n="",t=0,e=arguments.length;e>t;t++)r=arguments[t],n+=h.forceString(r);return n},t.get=function(){var r,n,t,e,u,i,o;if(i=arguments[0],e=2<=arguments.length?v.call(arguments,1):[],arguments.length<2)return"";for(i=h.forceString(i),n=i.length,u="",r=arguments.length,t=o=1;r>=1?r>=o:o>=r;t=r>=1?++o:--o)t=h.positiveIndex(arguments[t],n),t!==!1&&(u+=i[t]);return u},t.sort=function(r){return r=h.forceString(r).trim().split(""),h.insertSort(r).join("")},t.random=function(n,t){var e,u,i;for(n=h.forceNumber(n,1),u="",e=i=1;n>=1?n>=i:i>=n;e=n>=1?++i:--i)u+=r.random(t);return u},t.times=function(r,n){var t;if(""===(r=h.forceString(r)))return"";for(n=h.forceNumber(n,1),t="";n-->0;)t+=r;return t},t.regEscape=function(n){return""===(n=h.forceString(n))?n:t.xs(n,function(n){return S.call(r.REGEXP_SPECIAL_CHARS,n)>=0?"\\"+n:!0})},t.empty=function(r){return h.notString(r)||r.length>0?!1:!0},t.isAlpha=function(r){return""===(r=h.forceString(r))?!1:/^[a-z]*$/gi.test(r)},t.isNumeric=function(r){return""===(r=h.forceString(r))?!1:/^[0-9]*$/g.test(r)},t.isAlphaNumeric=function(r){return""===(r=h.forceString(r))?!1:/^[0-9|a-z]*$/gi.test(r)},t.isSpecial=function(r){return""===(r=h.forceString(r))?!1:/^[^0-9|a-z]*$/gi.test(r)},t.isSpace=function(r){return/^[ \t]+$/g.test(r)},t.xs=function(r,n){var t,e,u,i,o;if(null==r&&(r=""),r=h.forceString(r),-1===(e=r.length-1))return"";for(n=h.forceFunction(n,function(r){return r}),i="",t=o=0;e>=0?e>=o:o>=e;t=e>=0?++o:--o)(u=n(r[t],t))&&(u===!0?i+=r[t]:h.isStringOrNumber(u)&&(i+=u));return i},t.copy=function(r,n,t){return n=h.forceNumber(n),""===(r=h.forceString(r))||Math.abs(n)>r.length?"":(n>0&&(n-=1),r.substr(n,h.forceNumber(t,r.length)))},t.replace=function(r,n,e,u){var i;return null==r&&(r=""),null==n&&(n=""),null==e&&(e=""),null==u&&(u="g"),!h.isStringOrNumber(r)||"string"!==(i=h["typeof"](n))&&"number"!==i&&"regexp"!==i?h.forceString(r):(h.notRegExp(n)&&(n=t.regEscape(n+""),n=new RegExp(n,u)),(r+"").replace(n,e))},t.trim=function(r){return t.replace(r,/^\s+|\s+$/g)},t.trimLeft=function(r){return t.replace(r,/^\s+/g)},t.trimRight=function(r){return t.replace(r,/\s+$/g)},t.oneSpace=function(r){return t.replace(r,/\s+/g," ")},t.oneSpaceAndTrim=function(r){return t.oneSpace(t.trim(r))},t.toCamel=function(r,n){var e;return r=h.forceString(r),n=h.forceString(n,"-"),e=new RegExp(t.regEscape(n)+"([a-z])","ig"),t.replace(r,e,function(r,n){return n.toUpperCase()})},t.unCamel=function(r,n){return r=h.forceString(r),n=h.forceString(n,"-"),t.replace(r,/([A-Z])/g,n+"$1").toLowerCase()},t.shuffle=function(r){return r=h.forceString(r),h.shuffleArray((r+"").split("")).join("")},t.find=function(r,n,e){var u,i;if(u=[],""===(r=h.forceString(r)))return u;if(e=h.forceString(e,"g"),h.isStringOrNumber(n))n=new RegExp(t.regEscape(n+""),e);else{if(!h.isRegExp(n))return u;n=new RegExp(n.source,e)}if(n.global)for(;i=n.exec(r);)u.push(i.index+1);else(i=n.exec(r))&&u.push(i.index+1);return u},t.count=function(r,n){return t.find(r,n).length},t.contains=function(r,n){return t.count(r,n)>0},t.between=function(r,n,e){var u,i;return h.allStringOrNumber(r,n,e)?(n=t.regEscape(n+""),e=t.regEscape(e+""),u=new RegExp(n+"(.+)"+e),(null!=(i=u.exec(r+""))?i[1]:void 0)||""):""},t.slice=function(r,n,t){return r=h.forceString(r),n=h.forceNumber(n||1),!1!==(n=h.positiveIndex(n,r.length))?(t=h.forceNumber(t),r.slice(n,n+t)):""},t.truncate=function(r,n,e){return r=h.forceString(r),n=h.forceNumber(n,r.length),r=t.slice(r,1,n),r+h.forceString(e)},t.pop=function(r,n){return r=h.forceString(r),n=h.forceNumber(n,1),r.slice(0,-Math.abs(n))},t.split=function(r,n){var e,u,i,o,s;if(r=t.oneSpaceAndTrim(r),u=[],r.length<1)return u;for(n=h.forceString(n," "),e=r.split(n[0]||""),o=0,s=e.length;s>o;o++)i=e[o],i.match(/^\s$/)||u.push(t.trim(i));return u},t.reverse=function(r){var n,t,e,u;if(null==r&&(r=""),r=h.forceString(r),(t=r.length-1)<1)return r;for(e="",n=u=t;0>=t?0>=u:u>=0;n=0>=t?++u:--u)e+=r[n];return e},t.upper=function(){var r,n;return n=arguments[0],r=2<=arguments.length?v.call(arguments,1):[],e.changeCase.apply(e,[n,"toUpperCase"].concat(v.call(r)))},t.lower=function(){var r,n;return n=arguments[0],r=2<=arguments.length?v.call(arguments,1):[],e.changeCase.apply(e,[n,"toLowerCase"].concat(v.call(r)))},t.insert=function(){var r,n,t,e,u,i;if(u=arguments[0],n=arguments[1],e=3<=arguments.length?v.call(arguments,2):[],""===(u=h.forceString(u))||""===(n=h.forceString(n)))return u;if(e=h.sortNoDupAndReverse(e,u.length),t=g(e)-1,0>t)return u;for(r=i=0;t>=0?t>=i:i>=t;r=t>=0?++i:--i)r=e[r],r>u.length?u+=n:u=u.substr(0,r)+n+u.substr(r);return u},t.removeRange=function(r,n,e){var u;return r=h.forceString(r),""===r||!1===(n=h.positiveIndex(n,r.length))||0>(e=h.forceNumber(e,1))?r:(u=n+e,t.xs(r,function(r,t){return n>t||t>=u?!0:void 0}))},t.removePos=function(){var r,n,e;return e=arguments[0],n=2<=arguments.length?v.call(arguments,1):[],""===(e=h.forceString(e))?"":(r=n.map(function(r){return h.positiveIndex(r,e.length)}),t.xs(e,function(n,t){return S.call(r,t)>=0?void 0:!0}))},t.remove=function(){var r,n,e,u,i;if(n=arguments[0],e=2<=arguments.length?v.call(arguments,1):[],null==n&&(n=""),""===(n=h.forceString(n))||e.length<1)return n;for(u=0,i=e.length;i>u;u++)r=e[u],n=t.replace(n,r);return n},t.startsWith=function(r,n){return""===(r=h.forceString(r))||""===(n=h.forceString(n))?!1:(n=new RegExp("^"+t.regEscape(n)),n.test(r))},t.endsWith=function(r,n){return""===(r=h.forceString(r))||""===(n=h.forceString(n))?!1:(n=new RegExp(t.regEscape(n)+"$"),n.test(r))},t.wrap=function(r,n){var e;return null==r&&(r=""),null==n&&(n=""),e=function(e){return t.create(r,e,n)},e.wrap=function(t,e){return null==t&&(t=""),null==e&&(e=""),r=h.forceString(t)+r,n+=h.forceString(e)},e},t}(r),t.Types=i,t.Chars=r,t.crop=t.slice,s=function(){function r(){}return r.delimiter=" ",r.stringsFromArray=function(r){var n,t,e,u,i;for(n=[],i=h.forceArray(r),e=0,u=i.length;u>e;e++)t=i[e],h.isString(t)&&n.push(t);return n},r.numbersFromArray=function(r){var n,t,e,u,i;for(n=[],i=h.forceArray(r),e=0,u=i.length;u>e;e++)t=i[e],h.isNumber(t)&&n.push(t+0);return n},r.changeCase=function(n,e){var u,i,o,s,c,f,a,g,l,p,m;if(s=r.stringsFromArray(e),i=r.numbersFromArray(e),s.length>0&&this.set(t[n].apply(t,[this.string].concat(v.call(s)))),0===i[0]){for(l=[],c=0,a=i.length;a>c;c++)o=i[c],l.push(function(){var r,e,i;for(i=[],u=r=0,e=this.count-1;e>=0?e>=r:r>=e;u=e>=0?++r:--r)i.push(this.words[u]=t[n](this.words[u],o));return i}.call(this));return l}for(e.length<1&&(i=function(){p=[];for(var r=0,n=this.count;n>=0?n>=r:r>=n;n>=0?r++:r--)p.push(r);return p}.apply(this)),m=[],f=0,g=i.length;g>f;f++)u=i[f],u=h.positiveIndex(u,this.count),m.push(this.words[u]=t[n](this.words[u]));return m},r.applyToValidIndex=function(r,n,t){var e;return!1!==(e=h.positiveIndex(r,n))?t(e):void 0},r}(),o=function(r){function n(){this.set.apply(this,arguments)}return d(n,r),n.prototype.set=function(){var r,n,e,u,i,o,c;if(this.words=[],arguments.length<1)return this;for(e=0,i=arguments.length;i>e;e++)for(r=arguments[e],c=t.split(t.create(r),s.delimiter),u=0,o=c.length;o>u;u++)n=c[u],this.words.push(n);return this},n.prototype.get=function(){var r,n,e,u;if(arguments.length<1)return this.words.join(s.delimiter);for(n="",e=0,u=arguments.length;u>e;e++)r=arguments[e],r=h.positiveIndex(r,this.count),r!==!1&&(n+=this.words[r]+s.delimiter);return t.trim(n)},n.prototype.xs=function(r){var n,t,e,u,i,o,s;if(null==r&&(r=function(){return!0}),h.notFunction(r)||this.count<1)return this;for(e=[],s=this.words,n=i=0,o=s.length;o>i;n=++i)u=s[n],(t=r(u,n))&&(t===!0?e.push(u):h.isStringOrNumber(t)&&e.push(t+""));return this.words=e,this},n.prototype.find=function(r){var n;return n=[],""!==(r=h.forceString(r))&&this.xs(function(t,e){return t===r&&n.push(e+1),!0}),n},n.prototype.upper=function(){return s.changeCase.call(this,"upper",Array.prototype.slice.call(arguments)),this},n.prototype.lower=function(){return s.changeCase.call(this,"lower",Array.prototype.slice.call(arguments)),this},n.prototype.reverse=function(){var r,n,e;if(0===(null!=arguments?arguments[0]:void 0))this.xs(function(r){return t.reverse(r)});else if(arguments.length>0)for(n=0,e=arguments.length;e>n;n++)r=arguments[n],s.applyToValidIndex(r,this.count,function(r){return function(n){return r.words[n]=t.reverse(r.words[n])}}(this));else this.xs(function(r){return function(n,t){return r.get(r.count-t)}}(this));return this},n.prototype.shuffle=function(r){var n,e,u,i,o;if(null!=r)if(h.isString(r))for(e=0,i=arguments.length;i>e;e++)n=arguments[e],this.xs(function(){return function(r){return r===n?t.shuffle(r):!0}}(this));else if(0===r)this.xs(function(r){return t.shuffle(r)});else for(u=0,o=arguments.length;o>u;u++)n=arguments[u],s.applyToValidIndex(n,this.count,function(r){return function(n){return r.words[n]=t.shuffle(r.words[n])}}(this));else this.words=h.shuffleArray(this.words);return this},n.prototype.clear=function(){return this.words=[],this},n.prototype.remove=function(){var r,t,e,u,i,o,s;if(arguments.length<1)return this;for(t=[],u=0,o=arguments.length;o>u;u++)r=arguments[u],h.isString(r)?t.unshift(r):h.isNumber(r)&&t.push(n.positiveIndex(r,this.count));for(t=h.noDupAndReverse(h.insertSort(t)),e=i=0,s=t.length;s>i;e=++i)r=t[e],h.isNumber(r)?this.xs(function(){return function(n,t){return t!==r?!0:void 0}}(this)):h.isString(r)&&this.xs(function(n){return n!==r?!0:void 0});return this},n.prototype.pop=function(r){var n,t;for(r=Math.abs(h.forceNumber(r,1)),n=t=1;r>=1?r>=t:t>=r;n=r>=1?++t:--t)this.words.pop();return this},n.prototype.push=function(){var r,n,e;for(n=0,e=arguments.length;e>n;n++)r=arguments[n],""!==(r=h.forceString(r))&&this.words.push(t.trim(r));return this},n.prototype.shift=function(r){var n,t;for(r=h.forceNumber(r,1),n=t=1;r>=1?r>=t:t>=r;n=r>=1?++t:--t)this.words.shift();return this},n.prototype.prepend=function(){var r,n,e,u;for(n=0,e=0,u=arguments.length;u>e;e++)r=arguments[e],""!==(r=h.forceString(r))&&(this.words.splice(n,0,t.trim(r)),n++);return this},n.prototype.insert=function(){var r,n,e,u,i,o;for(r=arguments[0],u=2<=arguments.length?v.call(arguments,1):[],r=h.positiveIndex(r,this.count),n=0,i=0,o=u.length;o>i;i++)e=u[i],""!==(e=h.forceString(e))&&(this.words.splice(r+n,0,t.trim(e)),n++);return this},n.prototype.replace=function(r,n){return null==n&&(n=""),""===(n=t.trim(n))?this:(h.isNumber(r)?s.applyToValidIndex(r,this.count,function(r){return function(t){return r.words.splice(t,1,n)}}(this)):this.xs(function(t){return t===r?n:!0}),this)},n.prototype.sort=function(){return h.insertSort(this.words),this},n.prototype.startsWith=function(r){var t;return""===(r=h.forceString(r))?!1:(t=!0,r=new n(r),r.xs(function(r){return function(n,e){return n!==r.words[e]?t=!1:void 0}}(this)),t)},n.prototype.endsWith=function(r){var t,e,u,i,o;if(""===(r=h.forceString(r)))return!1;for(u=!0,t=1,r=new n(r),e=i=o=r.count;1>=o?1>=i:i>=1;e=1>=o?++i:--i)r.get(e)!==this.words[this.count-t++]&&(u=!1);return u},n}(t),Object.defineProperty(o.prototype,"$",{get:function(){return this.get()}}),Object.defineProperty(o.prototype,"string",{get:function(){return this.get()}}),Object.defineProperty(o.prototype,"count",{get:function(){return this.words.length}}),o.prototype.unshift=o.prototype.prepend,o.Strings=t,o.Types=i,o.Chars=r,"undefined"!=typeof window&&null!==window?window.Words=o:module.exports=o}).call(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
288707
0
4647
3
445
- Removedstrings.js@1.2.2
- Removedstrings.js@1.2.2(transitive)