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

1 line
10 KiB
JavaScript
Raw Normal View History

!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+"."