tablesorter/dist/js/extras/semver-mod.min.js
2015-03-28 15:00:32 -05:00

2 lines
13 KiB
JavaScript

/*! Modified semver.js for node.js (v4.3.3, 3/27/2015) */
!function(){function a(a,b){if(a instanceof d)return a;if("string"!=typeof a)return null;if(a.length>U)return null;var c=b?W[lb]:W[ib];if(!c.test(a))return null;try{return new d(a,b)}catch(e){return null}}function b(b,c){var d=a(b,c);return d?d.version:null}function c(b,c){var d=a(b.trim().replace(/^[=v]+/,""),c);return d?d.version:null}function d(a,b){if(a instanceof d){if(a.loose===b)return a;a=a.version}else if("string"!=typeof a)throw new TypeError("Invalid Version: "+a);if(a.length>U)throw new TypeError("version is longer than "+U+" characters");if(!(this instanceof d))return new d(a,b);R("SemVer",a,b),this.loose=b;var c=a.trim().match(b?W[lb]:W[ib]);if(!c)throw new TypeError("Invalid Version: "+a);if(this.raw=a,this.major=+c[1],this.minor=+c[2],this.patch=+c[3],this.major>V||this.major<0)throw new TypeError("Invalid major version");if(this.minor>V||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>V||this.patch<0)throw new TypeError("Invalid patch version");this.prerelease=c[4]?c[4].split(".").map(function(a){if(/^[0-9]+$/.test(a)){var b=+a;if(b>=0&&V>b)return b}return a}):[],this.build=c[5]?c[5].split("."):[],this.format()}function e(a,b,c,e){"string"==typeof c&&(e=c,c=void 0);try{return new d(a,c).inc(b,e).version}catch(f){return null}}function f(b,c){if(s(b,c))return null;var d=a(b),e=a(c);if(d.prerelease.length||e.prerelease.length){for(var f in d)if(("major"===f||"minor"===f||"patch"===f)&&d[f]!==e[f])return"pre"+f;return"prerelease"}for(var f in d)if(("major"===f||"minor"===f||"patch"===f)&&d[f]!==e[f])return f}function g(a,b){var c=Lb.test(a),d=Lb.test(b);return c&&d&&(a=+a,b=+b),c&&!d?-1:d&&!c?1:b>a?-1:a>b?1:0}function h(a,b){return g(b,a)}function i(a,b){return new d(a,b).major}function j(a,b){return new d(a,b).minor}function k(a,b){return new d(a,b).patch}function l(a,b,c){return new d(a,c).compare(b)}function m(a,b){return l(a,b,!0)}function n(a,b,c){return l(b,a,c)}function o(a,b){return a.sort(function(a,c){return T.compare(a,c,b)})}function p(a,b){return a.sort(function(a,c){return T.rcompare(a,c,b)})}function q(a,b,c){return l(a,b,c)>0}function r(a,b,c){return l(a,b,c)<0}function s(a,b,c){return 0===l(a,b,c)}function t(a,b,c){return 0!==l(a,b,c)}function u(a,b,c){return l(a,b,c)>=0}function v(a,b,c){return l(a,b,c)<=0}function w(a,b,c,d){var e;switch(b){case"===":"object"==typeof a&&(a=a.version),"object"==typeof c&&(c=c.version),e=a===c;break;case"!==":"object"==typeof a&&(a=a.version),"object"==typeof c&&(c=c.version),e=a!==c;break;case"":case"=":case"==":e=s(a,c,d);break;case"!=":e=t(a,c,d);break;case">":e=q(a,c,d);break;case">=":e=u(a,c,d);break;case"<":e=r(a,c,d);break;case"<=":e=v(a,c,d);break;default:throw new TypeError("Invalid operator: "+b)}return e}function x(a,b){if(a instanceof x){if(a.loose===b)return a;a=a.value}return this instanceof x?(R("comparator",a,b),this.loose=b,this.parse(a),this.value=this.semver===Mb?"":this.operator+this.semver.version,void R("comp",this)):new x(a,b)}function y(a,b){if(a instanceof y&&a.loose===b)return a;if(!(this instanceof y))return new y(a,b);if(this.loose=b,this.raw=a,this.set=a.split(/\s*\|\|\s*/).map(function(a){return this.parseRange(a.trim())},this).filter(function(a){return a.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+a);this.format()}function z(a,b){return new y(a,b).set.map(function(a){return a.map(function(a){return a.value}).join(" ").trim().split(" ")})}function A(a,b){return R("comp",a),a=E(a,b),R("caret",a),a=C(a,b),R("tildes",a),a=G(a,b),R("xrange",a),a=I(a,b),R("stars",a),a}function B(a){return!a||"x"===a.toLowerCase()||"*"===a}function C(a,b){return a.trim().split(/\s+/).map(function(a){return D(a,b)}).join(" ")}function D(a,b){var c=b?W[xb]:W[wb];return a.replace(c,function(b,c,d,e,f){R("tilde",a,b,c,d,e,f);var g;return B(c)?g="":B(d)?g=">="+c+".0.0 <"+(+c+1)+".0.0":B(e)?g=">="+c+"."+d+".0 <"+c+"."+(+d+1)+".0":f?(R("replaceTilde pr",f),"-"!==f.charAt(0)&&(f="-"+f),g=">="+c+"."+d+"."+e+f+" <"+c+"."+(+d+1)+".0"):g=">="+c+"."+d+"."+e+" <"+c+"."+(+d+1)+".0",R("tilde return",g),g})}function E(a,b){return a.trim().split(/\s+/).map(function(a){return F(a,b)}).join(" ")}function F(a,b){R("caret",a,b);var c=b?W[Cb]:W[Bb];return a.replace(c,function(b,c,d,e,f){R("caret",a,b,c,d,e,f);var g;return B(c)?g="":B(d)?g=">="+c+".0.0 <"+(+c+1)+".0.0":B(e)?g="0"===c?">="+c+"."+d+".0 <"+c+"."+(+d+1)+".0":">="+c+"."+d+".0 <"+(+c+1)+".0.0":f?(R("replaceCaret pr",f),"-"!==f.charAt(0)&&(f="-"+f),g="0"===c?"0"===d?">="+c+"."+d+"."+e+f+" <"+c+"."+d+"."+(+e+1):">="+c+"."+d+"."+e+f+" <"+c+"."+(+d+1)+".0":">="+c+"."+d+"."+e+f+" <"+(+c+1)+".0.0"):(R("no pr"),g="0"===c?"0"===d?">="+c+"."+d+"."+e+" <"+c+"."+d+"."+(+e+1):">="+c+"."+d+"."+e+" <"+c+"."+(+d+1)+".0":">="+c+"."+d+"."+e+" <"+(+c+1)+".0.0"),R("caret return",g),g})}function G(a,b){return R("replaceXRanges",a,b),a.split(/\s+/).map(function(a){return H(a,b)}).join(" ")}function H(a,b){a=a.trim();var c=b?W[sb]:W[rb];return a.replace(c,function(b,c,d,e,f,g){R("xRange",a,b,c,d,e,f,g);var h=B(d),i=h||B(e),j=i||B(f),k=j;return"="===c&&k&&(c=""),h?b=">"===c||"<"===c?"<0.0.0":"*":c&&k?(i&&(e=0),j&&(f=0),">"===c?(c=">=",i?(d=+d+1,e=0,f=0):j&&(e=+e+1,f=0)):"<="===c&&(c="<",i?d=+d+1:e=+e+1),b=c+d+"."+e+"."+f):i?b=">="+d+".0.0 <"+(+d+1)+".0.0":j&&(b=">="+d+"."+e+".0 <"+d+"."+(+e+1)+".0"),R("xRange return",b),b})}function I(a,b){return R("replaceStars",a,b),a.trim().replace(W[Jb],"")}function J(a,b,c,d,e,f,g,h,i,j,k,l){return b=B(c)?"":B(d)?">="+c+".0.0":B(e)?">="+c+"."+d+".0":">="+b,h=B(i)?"":B(j)?"<"+(+i+1)+".0.0":B(k)?"<"+i+"."+(+j+1)+".0":l?"<="+i+"."+j+"."+k+"-"+l:"<="+h,(b+" "+h).trim()}function K(a,b){for(var c=0;c<a.length;c++)if(!a[c].test(b))return!1;if(b.prerelease.length){for(var c=0;c<a.length;c++){if(R(a[c].semver),a[c].semver===Mb)return!0;if(a[c].semver.prerelease.length>0){var d=a[c].semver;if(d.major===b.major&&d.minor===b.minor&&d.patch===b.patch)return!0}}return!1}return!0}function L(a,b,c){try{b=new y(b,c)}catch(d){return!1}return b.test(a)}function M(a,b,c){return a.filter(function(a){return L(a,b,c)}).sort(function(a,b){return n(a,b,c)})[0]||null}function N(a,b){try{return new y(a,b).range||"*"}catch(c){return null}}function O(a,b,c){return Q(a,b,"<",c)}function P(a,b,c){return Q(a,b,">",c)}function Q(a,b,c,e){a=new d(a,e),b=new y(b,e);var f,g,h,i,j;switch(c){case">":f=q,g=v,h=r,i=">",j=">=";break;case"<":f=r,g=u,h=q,i="<",j="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(L(a,b,e))return!1;for(var k=0;k<b.set.length;++k){var l=b.set[k],m=null,n=null;if(l.forEach(function(a){m=m||a,n=n||a,f(a.semver,m.semver,e)?m=a:h(a.semver,n.semver,e)&&(n=a)}),m.operator===i||m.operator===j)return!1;if((!n.operator||n.operator===i)&&g(a,n.semver))return!1;if(n.operator===j&&h(a,n.semver))return!1}return!0}var R,S={exports:{}},T=S.exports=d;R="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?function(){var a=Array.prototype.slice.call(arguments,0);a.unshift("SEMVER"),console.log.apply(console,a)}:function(){},T.SEMVER_SPEC_VERSION="2.0.0";var U=256,V=Number.MAX_SAFE_INTEGER||9007199254740991,W=T.re=[],X=T.src=[],Y=0,Z=Y++;X[Z]="0|[1-9]\\d*";var $=Y++;X[$]="[0-9]+";var _=Y++;X[_]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var ab=Y++;X[ab]="("+X[Z]+")\\.("+X[Z]+")\\.("+X[Z]+")";var bb=Y++;X[bb]="("+X[$]+")\\.("+X[$]+")\\.("+X[$]+")";var cb=Y++;X[cb]="(?:"+X[Z]+"|"+X[_]+")";var db=Y++;X[db]="(?:"+X[$]+"|"+X[_]+")";var eb=Y++;X[eb]="(?:-("+X[cb]+"(?:\\."+X[cb]+")*))";var fb=Y++;X[fb]="(?:-?("+X[db]+"(?:\\."+X[db]+")*))";var gb=Y++;X[gb]="[0-9A-Za-z-]+";var hb=Y++;X[hb]="(?:\\+("+X[gb]+"(?:\\."+X[gb]+")*))";var ib=Y++,jb="v?"+X[ab]+X[eb]+"?"+X[hb]+"?";X[ib]="^"+jb+"$";var kb="[v=\\s]*"+X[bb]+X[fb]+"?"+X[hb]+"?",lb=Y++;X[lb]="^"+kb+"$";var mb=Y++;X[mb]="((?:<|>)?=?)";var nb=Y++;X[nb]=X[$]+"|x|X|\\*";var ob=Y++;X[ob]=X[Z]+"|x|X|\\*";var pb=Y++;X[pb]="[v=\\s]*("+X[ob]+")(?:\\.("+X[ob]+")(?:\\.("+X[ob]+")(?:"+X[eb]+")?"+X[hb]+"?)?)?";var qb=Y++;X[qb]="[v=\\s]*("+X[nb]+")(?:\\.("+X[nb]+")(?:\\.("+X[nb]+")(?:"+X[fb]+")?"+X[hb]+"?)?)?";var rb=Y++;X[rb]="^"+X[mb]+"\\s*"+X[pb]+"$";var sb=Y++;X[sb]="^"+X[mb]+"\\s*"+X[qb]+"$";var tb=Y++;X[tb]="(?:~>?)";var ub=Y++;X[ub]="(\\s*)"+X[tb]+"\\s+",W[ub]=new RegExp(X[ub],"g");var vb="$1~",wb=Y++;X[wb]="^"+X[tb]+X[pb]+"$";var xb=Y++;X[xb]="^"+X[tb]+X[qb]+"$";var yb=Y++;X[yb]="(?:\\^)";var zb=Y++;X[zb]="(\\s*)"+X[yb]+"\\s+",W[zb]=new RegExp(X[zb],"g");var Ab="$1^",Bb=Y++;X[Bb]="^"+X[yb]+X[pb]+"$";var Cb=Y++;X[Cb]="^"+X[yb]+X[qb]+"$";var Db=Y++;X[Db]="^"+X[mb]+"\\s*("+kb+")$|^$";var Eb=Y++;X[Eb]="^"+X[mb]+"\\s*("+jb+")$|^$";var Fb=Y++;X[Fb]="(\\s*)"+X[mb]+"\\s*("+kb+"|"+X[pb]+")",W[Fb]=new RegExp(X[Fb],"g");var Gb="$1$2$3",Hb=Y++;X[Hb]="^\\s*("+X[pb]+")\\s+-\\s+("+X[pb]+")\\s*$";var Ib=Y++;X[Ib]="^\\s*("+X[qb]+")\\s+-\\s+("+X[qb]+")\\s*$";var Jb=Y++;X[Jb]="(<|>)?=?\\s*\\*";for(var Kb=0;Y>Kb;Kb++)R(Kb,X[Kb]),W[Kb]||(W[Kb]=new RegExp(X[Kb]));T.parse=a,T.valid=b,T.clean=c,window.semver=T.SemVer=d,d.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},d.prototype.inspect=function(){return'<SemVer "'+this+'">'},d.prototype.toString=function(){return this.version},d.prototype.compare=function(a){return R("SemVer.compare",this.version,this.loose,a),a instanceof d||(a=new d(a,this.loose)),this.compareMain(a)||this.comparePre(a)},d.prototype.compareMain=function(a){return a instanceof d||(a=new d(a,this.loose)),g(this.major,a.major)||g(this.minor,a.minor)||g(this.patch,a.patch)},d.prototype.comparePre=function(a){if(a instanceof d||(a=new d(a,this.loose)),this.prerelease.length&&!a.prerelease.length)return-1;if(!this.prerelease.length&&a.prerelease.length)return 1;if(!this.prerelease.length&&!a.prerelease.length)return 0;var b=0;do{var c=this.prerelease[b],e=a.prerelease[b];if(R("prerelease compare",b,c,e),void 0===c&&void 0===e)return 0;if(void 0===e)return 1;if(void 0===c)return-1;if(c!==e)return g(c,e)}while(++b)},d.prototype.inc=function(a,b){switch(a){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",b);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",b);break;case"prepatch":this.prerelease.length=0,this.inc("patch",b),this.inc("pre",b);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",b),this.inc("pre",b);break;case"major":(0!==this.minor||0!==this.patch||0===this.prerelease.length)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(0!==this.patch||0===this.prerelease.length)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var c=this.prerelease.length;--c>=0;)"number"==typeof this.prerelease[c]&&(this.prerelease[c]++,c=-2);-1===c&&this.prerelease.push(0)}b&&(this.prerelease[0]===b?isNaN(this.prerelease[1])&&(this.prerelease=[b,0]):this.prerelease=[b,0]);break;default:throw new Error("invalid increment argument: "+a)}return this.format(),this},T.inc=e,T.diff=f,T.compareIdentifiers=g;var Lb=/^[0-9]+$/;T.rcompareIdentifiers=h,T.major=i,T.minor=j,T.patch=k,T.compare=l,T.compareLoose=m,T.rcompare=n,T.sort=o,T.rsort=p,T.gt=q,T.lt=r,T.eq=s,T.neq=t,T.gte=u,T.lte=v,T.cmp=w,T.Comparator=x;var Mb={};x.prototype.parse=function(a){var b=this.loose?W[Db]:W[Eb],c=a.match(b);if(!c)throw new TypeError("Invalid comparator: "+a);this.operator=c[1],"="===this.operator&&(this.operator=""),this.semver=c[2]?new d(c[2],this.loose):Mb},x.prototype.inspect=function(){return'<SemVer Comparator "'+this+'">'},x.prototype.toString=function(){return this.value},x.prototype.test=function(a){return R("Comparator.test",a,this.loose),this.semver===Mb?!0:("string"==typeof a&&(a=new d(a,this.loose)),w(a,this.operator,this.semver,this.loose))},T.Range=y,y.prototype.inspect=function(){return'<SemVer Range "'+this.range+'">'},y.prototype.format=function(){return this.range=this.set.map(function(a){return a.join(" ").trim()}).join("||").trim(),this.range},y.prototype.toString=function(){return this.range},y.prototype.parseRange=function(a){var b=this.loose;a=a.trim(),R("range",a,b);var c=b?W[Ib]:W[Hb];a=a.replace(c,J),R("hyphen replace",a),a=a.replace(W[Fb],Gb),R("comparator trim",a,W[Fb]),a=a.replace(W[ub],vb),a=a.replace(W[zb],Ab),a=a.split(/\s+/).join(" ");var d=b?W[Db]:W[Eb],e=a.split(" ").map(function(a){return A(a,b)}).join(" ").split(/\s+/);return this.loose&&(e=e.filter(function(a){return!!a.match(d)})),e=e.map(function(a){return new x(a,b)})},T.toComparators=z,y.prototype.test=function(a){if(!a)return!1;"string"==typeof a&&(a=new d(a,this.loose));for(var b=0;b<this.set.length;b++)if(K(this.set[b],a))return!0;return!1},T.satisfies=L,T.maxSatisfying=M,T.validRange=N,T.ltr=O,T.gtr=P,T.outside=Q,"function"==typeof define&&define.amd&&define(T)}();