tablesorter/dist/js/extras/semver-mod.min.js

1 line
10 KiB
JavaScript

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