rx-util

rxliuli 在浏览器上使用的 js 工具集

目前为 2019-05-04 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/382120/695171/rx-util.js

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).rx={})}(this,function(t){"use strict";function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"unknown",n=document.createElement("a");n.download=e,n.style.display="none",n.href=URL.createObjectURL(t),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var u=e(function(t){var e=function(i){var c,t=Object.prototype,f=t.hasOwnProperty,e="function"==typeof Symbol?Symbol:{},o=e.iterator||"@@iterator",n=e.asyncIterator||"@@asyncIterator",r=e.toStringTag||"@@toStringTag";function a(t,e,n,r){var i,a,u,c,o=e&&e.prototype instanceof g?e:g,f=Object.create(o.prototype),l=new L(r||[]);return f._invoke=(i=t,a=n,u=l,c=h,function(t,e){if(c===p)throw new Error("Generator is already running");if(c===y){if("throw"===t)throw e;return M()}for(u.method=t,u.arg=e;;){var n=u.delegate;if(n){var r=E(n,u);if(r){if(r===d)continue;return r}}if("next"===u.method)u.sent=u._sent=u.arg;else if("throw"===u.method){if(c===h)throw c=y,u.arg;u.dispatchException(u.arg)}else"return"===u.method&&u.abrupt("return",u.arg);c=p;var o=s(i,a,u);if("normal"===o.type){if(c=u.done?y:v,o.arg===d)continue;return{value:o.arg,done:u.done}}"throw"===o.type&&(c=y,u.method="throw",u.arg=o.arg)}}),f}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=a;var h="suspendedStart",v="suspendedYield",p="executing",y="completed",d={};function g(){}function u(){}function l(){}var m={};m[o]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w(P([])));b&&b!==t&&f.call(b,o)&&(m=b);var x=l.prototype=g.prototype=Object.create(m);function S(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function k(c){var e;this._invoke=function(n,r){function t(){return new Promise(function(t,e){!function e(t,n,r,o){var i=s(c[t],c,n);if("throw"!==i.type){var a=i.arg,u=a.value;return u&&"object"==typeof u&&f.call(u,"__await")?Promise.resolve(u.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(u).then(function(t){a.value=t,r(a)},function(t){return e("throw",t,r,o)})}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function E(t,e){var n=t.iterator[e.method];if(n===c){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=c,E(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,d;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=c),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(f.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=c,t.done=!0,t};return r.next=r}}return{next:M}}function M(){return{value:c,done:!0}}return u.prototype=x.constructor=l,l.constructor=u,l[r]=u.displayName="GeneratorFunction",i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===u||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,r in t||(t[r]="GeneratorFunction")),t.prototype=Object.create(x),t},i.awrap=function(t){return{__await:t}},S(k.prototype),k.prototype[n]=function(){return this},i.AsyncIterator=k,i.async=function(t,e,n,r){var o=new k(a(t,e,n,r));return i.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},S(x),x[r]="Generator",x[o]=function(){return this},x.toString=function(){return"[object Generator]"},i.keys=function(n){var r=[];for(var t in n)r.push(t);return r.reverse(),function t(){for(;r.length;){var e=r.pop();if(e in n)return t.value=e,t.done=!1,t}return t.done=!0,t}},i.values=P,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&f.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=c)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function t(t,e){return i.type="throw",i.arg=n,r.next=t,e&&(r.method="next",r.arg=c),!!e}for(var e=this.tryEntries.length-1;0<=e;--e){var o=this.tryEntries[e],i=o.completion;if("root"===o.tryLoc)return t("end");if(o.tryLoc<=this.prev){var a=f.call(o,"catchLoc"),u=f.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return t(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&f.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;0<=e;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;T(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=c),d}},i}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}});function c(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}var a=function(u){return function(){var t=this,a=arguments;return new Promise(function(e,n){var r=u.apply(t,a);function o(t){c(r,e,n,o,i,"next",t)}function i(t){c(r,e,n,o,i,"throw",t)}o(void 0)})}};function n(){return(n=a(u.mark(function t(e){var n,r=arguments;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=1<r.length&&void 0!==r[1]?r[1]:"unknown.txt",i(new Blob([e],{type:"text/plain"}),n);case 3:case"end":return t.stop()}},t)}))).apply(this,arguments)}function r(){return(r=a(u.mark(function t(e){var n,r,o=arguments;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=1<o.length&&void 0!==o[1]?o[1]:e.substr(e.lastIndexOf("/")),t.prev=1,t.next=4,fetch(e);case 4:return r=t.sent,t.next=7,r.blob();case 7:i(t.sent,n),t.next=14;break;case 11:return t.prev=11,t.t0=t.catch(1),t.abrupt("return",console.log("下载出错了 ",t.t0));case 14:case"end":return t.stop()}},t,null,[[1,11]])}))).apply(this,arguments)}var o=function(t){if(Array.isArray(t))return t};var f=function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n};var l=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var s=function(t,e){return o(t)||f(t,e)||l()};function h(){return(h=a(u.mark(function t(e,n){var r,o,i,a=arguments;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=2<a.length&&void 0!==a[2]?a[2]:{},t.next=3,fetch(e,r);case 3:return o=t.sent,t.next=6,o.blob();case 6:i=t.sent,n.src=window.URL.createObjectURL(i);case 8:case"end":return t.stop()}},t)}))).apply(this,arguments)}var m=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},v=function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=e.href,r=void 0===n?"":n,o=e.website,i=void 0===o?"":o,a=e.protocol,u=void 0===a?"":a,c=e.domain,f=void 0===c?"":c,l=e.accessPath,s=void 0===l?"":l,h=e.params,v=void 0===h?{}:h,p=e.url,y=void 0===p?"":p,d=e.port,g=void 0===d?0:d;m(this,t),this.href=r,this.website=i,this.protocol=u,this.domain=f,this.accessPath=s,this.params=v,this.url=y,this.port=g},p={http:80,https:443,ssh:22,ftp:21};function y(r){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=t.type,o=void 0===e?y.DataURL:e,n=t.encoding,i=void 0===n?"UTF-8":n;return new Promise(function(e,n){r||n(new Error("file not exists"));var t=new FileReader;t.onload=function(t){e(t.target.result)},t.onerror=function(t){n(t)},t[o](r,i)})}function d(t,e){var n={"y+":t.getFullYear(),"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),"S+":t.getMilliseconds()};for(var r in n)if(new RegExp("("+r+")").test(e))if("y+"===r)e=e.replace(RegExp.$1,(""+n[r]).substr(4-RegExp.$1.length));else if("S+"===r){var o=RegExp.$1.length;o=1===o?3:o,e=e.replace(RegExp.$1,("00"+n[r]).substr((""+n[r]).length-1,o))}else e=e.replace(RegExp.$1,1===RegExp.$1.length?n[r]:("00"+n[r]).substr((""+n[r]).length));return e}y.DataURL="readAsDataURL",y.Text="readAsText",y.BinaryString="readAsBinaryString",y.ArrayBuffer="readAsArrayBuffer";var g="yyyy-MM-ddThh:mm:ss.SSS",w=function(t,e){return encodeURIComponent(t)+"="+encodeURIComponent(e)};function b(t,e){var n=null,r=new Promise(function(t,e){n=function(){e(new Error("abort promise"))}}),o=Promise.race([t,r]);return setTimeout(function(){n()},e),o}var x=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}};var S=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)};var k=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")};var E=function(t){return x(t)||S(t)||k()};function O(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var T=function(t,e,n){return e&&O(t.prototype,e),n&&O(t,n),t},L=function(n){return new Promise(function(t){if("number"==typeof n)setTimeout(t,n);else if("function"==typeof n)var e=setInterval(function(){n()&&(clearInterval(e),t())},100);else t()})},P=function(){function i(t){var e=t.timeout,n=void 0===e?1e4:e,r=t.limit,o=void 0===r?10:r;m(this,i),this.timeout=n,this.limit=o,this.execCount=0,this.waitArr=[]}return T(i,[{key:"fetch",value:function(n){function t(t,e){return n.apply(this,arguments)}return t.toString=function(){return n.toString()},t}(function(){var n=a(u.mark(function t(e,n){var r,o=this,i=arguments;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(){var t=a(u.mark(function t(){var e;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return o.execCount++,e=o.waitArr.shift(),t.prev=2,t.next=5,b(fetch.apply(void 0,E(e)),o.timeout);case 5:return t.abrupt("return",t.sent);case 6:return t.prev=6,o.execCount--,t.finish(6);case 9:case"end":return t.stop()}},t,null,[[2,,6,9]])}));return function(){return t.apply(this,arguments)}}(),this.waitArr.push(i),t.next=4,L(function(){return o.execCount<o.limit});case 4:return t.abrupt("return",r());case 5:case"end":return t.stop()}},t,this)}));return function(t,e){return n.apply(this,arguments)}}())}]),i}();function M(t){for(var e=[];;){var n=t.next();if(n.done)break;e.push(n.value)}return e}function A(){return(A=a(u.mark(function t(e,n){var r,o;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=[],t.t0=u.keys(e);case 2:if((t.t1=t.t0()).done){t.next=11;break}return o=t.t1.value,t.t2=r,t.next=7,n(e[o]);case 7:t.t3=t.sent,r=t.t2.concat.call(t.t2,t.t3),t.next=2;break;case 11:return t.abrupt("return",r);case 12:case"end":return t.stop()}},t)}))).apply(this,arguments)}function R(t,n){return t.reduce(function(t,e){return t.concat(n(e))},[])}function j(t,r){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(t,e){return t.push(e),t},i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:function(){return[]};return t.reduce(function(t,e){var n=r(e);return t.has(n)||t.set(n,i()),t.set(n,o(t.get(n),e)),t},new Map)}function D(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(t){return t};return t.reduce(function(t,e){return t.set(n(e),r(e)),t},new Map)}function C(t,e){return e<=0?"":t+C(t,e-1)}var F,I=function t(e,n,r,o){m(this,t),this.name=e,this.format=n,this.value=r,this.index=o},_={year:"y{4}|y{2}",month:"M{1,2}",day:"d{1,2}",hour:"h{1,2}",minute:"m{1,2}",second:"s{1,2}",millieSecond:"S{1,3}"};function U(o,t){var e={year:(new Date).getFullYear().toString(),month:"01",day:"01",hour:"00",minute:"00",second:"00",millieSecond:"000"},i=[];for(var n in _){var r=new RegExp(_[n]);if(r.test(t)){var a=r.exec(t)[0],u=C("`",a.length),c=t.indexOf(a);t=t.replace(a,u),i.push(new I(n,C("\\d",a.length),null,c))}else i.push(new I(n,null,e[n],-1))}if(t=t.replace(new RegExp("`","g"),"\\d"),!new RegExp("^".concat(t,"$")).test(o))return null;i.filter(function(t){return t.format}).sort(function(t,e){return t.index-e.index}).map(function(t){var e=new RegExp(t.format).exec(o);return null!==e&&0<e.length&&(o=o.replace(e[0],""),t.value=e[0]),t}).forEach(function(t,e){var n=t.format,r=new RegExp(n).exec(o);null!==r&&0<r.length&&(o=o.replace(r[0],""),i[e].value=r[0])});var f=D(i,function(t){return t.name},function(t){return t.value});2===f.get("year").length&&f.set("year",e.year.substr(0,2).concat(f.get("year")));var l="".concat(f.get("year"),"-").concat(f.get("month"),"-").concat(f.get("day"),"T").concat(f.get("hour"),":").concat(f.get("minute"),":").concat(f.get("second"),".").concat(f.get("millieSecond"));return new Date(l)}function N(t){return t.selectionStart}function Y(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e;t.focus(),t.setSelectionRange(e,n)}function B(t){return t&&"string"==typeof t?t.toLowerCase():t}document.addEventListener("focus",function(t){F=t.target},!0),document.addEventListener("blur",function(){F=null},!0);function z(t){return t}var $=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:void 0;try{for(var n=arguments.length,r=new Array(2<n?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return t.apply(void 0,r)}catch(t){return e}},G=e(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=r=function(t){return n(t)}:e.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(t)}e.exports=r});var J=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var q=function(t,e){return!e||"object"!==G(e)&&"function"!=typeof e?J(t):e},H=e(function(e){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}e.exports=n}),W=e(function(n){function r(t,e){return n.exports=r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},r(t,e)}n.exports=r});var Z=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&W(t,e)};function K(e){var a;return function(t){function i(){var t,e;if(m(this,i),a)return q(e,a);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=q(this,(t=H(i)).call.apply(t,[this].concat(r))),a=J(e),e}return Z(i,e),i}()}var Q=e(function(r){function o(t,e,n){return!function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?r.exports=o=function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&W(o,n.prototype),o}:r.exports=o=Reflect.construct,o.apply(null,arguments)}r.exports=o}),V=function(){function t(){m(this,t)}return T(t,null,[{key:"getFactory",value:function(){var n=new Map;return new(function(){function t(){m(this,t)}return T(t,[{key:"register",value:function(t,e){return n.set(t,K(e)),e}},{key:"getInstance",value:function(t){var e=n.get(t);return e?Q(e,E(Array.from(arguments).slice(1))):null}}]),t}())}}]),t}(),X=function(t){return new Proxy(t,{apply:function(t,e,n){var r=performance.now(),o=Reflect.apply(t,e,n);return o instanceof Promise?o.then(function(){return performance.now()-r}):performance.now()-r}})()};var tt=new RegExp("^(-?\\d+)(.\\d+)?$");var et=new RegExp("^-?\\d+$");function nt(t){return t&&0!==t.trim().length?t:null}function rt(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=new Set(n);return Object.entries(t).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return i.has(r)||(t[r]=o),t},{})}var ot=new(function(){function t(){m(this,t)}return T(t,[{key:"dayStart",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(d(t,"yyyy-MM-dd"),"T00:00:00.000"))}},{key:"dayEnd",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(d(t,"yyyy-MM-dd"),"T23:59:59.999"))}},{key:"yearStart",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(t.getFullYear(),"-01-01T00:00:00.000"))}},{key:"yearEnd",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(t.getFullYear(),"-12-31T23:59:59.999"))}}]),t}());function it(t,e,n){return e<=t&&t<n}var at=new(function(){function t(){m(this,t)}return T(t,[{key:"dayStart",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(d(t,"yyyy-MM-dd"),"T00:00:00.000"))}},{key:"dayEnd",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(d(t,"yyyy-MM-dd"),"T23:59:59.999"))}},{key:"yearStart",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(t.getFullYear(),"-01-01T00:00:00.000"))}},{key:"yearEnd",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Date;return new Date("".concat(t.getFullYear(),"-12-31T23:59:59.999"))}}]),t}()),ut=function(){function e(t){m(this,e),this.date=t}return T(e,[{key:"year",value:function(){return this.date.getFullYear()}},{key:"month",value:function(){return this.date.getMonth()}},{key:"monthOfYear",value:function(){return this.date.getMonth()+1}},{key:"dayOfYear",value:function(){return Math.ceil((this.date.getTime()-at.yearStart(this.date).getTime())/864e5)}},{key:"dayOfMonth",value:function(){return this.date.getDate()}},{key:"dayOfWeek",value:function(){return this.date.getDay()}},{key:"weekOfYear",value:function(){return Math.ceil(this.dayOfYear()/7)}},{key:"weekOfMonth",value:function(){return Math.ceil(this.dayOfMonth()/7)}},{key:"quarter",value:function(){var t=this.month();return it(t,0,3)?1:it(t,3,6)?2:it(t,6,9)?3:4}},{key:"hour",value:function(){return this.date.getHours()}},{key:"minute",value:function(){return this.date.getMinutes()}},{key:"second",value:function(){return this.date.getSeconds()}},{key:"milliSecond",value:function(){return this.date.getMilliseconds()}}]),e}();var ct=function(){function n(t,e){m(this,n),this.start=t,this.end=e}return T(n,[{key:"milliSecond",value:function(){return this.end.getTime()-this.start.getTime()}},{key:"second",value:function(){return Math.floor(this.milliSecond()/1e3)}},{key:"minute",value:function(){return Math.floor(this.second()/60)}},{key:"hour",value:function(){return Math.floor(this.minute()/60)}},{key:"day",value:function(){return Math.floor(this.hour()/24)}},{key:"month",value:function(){var t=this.year(),e=this.end.getMonth()-this.start.getMonth();return 12*t+e}},{key:"year",value:function(){return this.end.getFullYear()-this.start.getFullYear()}}]),n}();var ft=function(o){var i,a=!0;return function(){if(!1===a)return i;a=!1;for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=o.call.apply(o,[this].concat(e));return r instanceof Promise?r.then(function(t){return i=t}):i=r}},lt=function(a){var u=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return JSON.stringify(e)},c=new Map;return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=u.apply(void 0,e),o=c.get(r);if(void 0!==o)return o;var i=a.call.apply(a,[this].concat(e));return i instanceof Promise?i.then(function(t){return c.set(r,t),t}):(c.set(r,i),i)}};var st=function t(e,n,r){m(this,t),this.left=e,this.right=n,this.common=r};var ht=u.mark(vt);function vt(){var e;return u.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=0;case 1:return t.next=3,e;case 3:e++,t.next=1;break;case 6:case"end":return t.stop()}},ht)}var pt=ft(vt);var yt=function(){function t(){m(this,t)}return T(t,[{key:"from",value:function(t){throw new Error("子类必须重写 from 函数")}},{key:"to",value:function(t){throw new Error("子类必须重写 to 函数")}}]),t}(),dt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return Z(e,yt),T(e,[{key:"from",value:function(t){for(var e=[],n=t.length,r=0,o=0;o<n;o++){var i=t.charAt(o);"A"<=i&&i<="Z"&&(0!==o&&e.push(t.substring(r,o)),r=o)}return r!==t.length&&e.push(t.substring(r,t.length)),e}}]),e}(),gt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return Z(e,dt),T(e,[{key:"to",value:function(t){var e=t.map(function(t){return t.substring(0,1).toUpperCase()+t.substring(1)}).join();return e.substring(0,1).toLowerCase()+e.substring(1)}}]),e}(),mt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return Z(e,dt),T(e,[{key:"to",value:function(t){return t.map(function(t){return t.substring(0,1).toUpperCase()+t.substring(1)}).join()}}]),e}(),wt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return Z(e,yt),T(e,[{key:"from",value:function(t){return t.split("_")}}]),e}(),bt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return Z(e,wt),T(e,[{key:"to",value:function(t){return t.map(function(t){return t.toLowerCase()}).join("_")}}]),e}(),xt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return Z(e,wt),T(e,[{key:"to",value:function(t){return t.map(function(t){return t.toUpperCase()}).join("_")}}]),e}(),St={Camel:Symbol(1),Pascal:Symbol(2),Snake:Symbol(3),ScreamingSnake:Symbol(4)},kt=function(){function t(){m(this,t)}return T(t,null,[{key:"getInstance",value:function(t){switch(t){case St.Camel:return new gt;case St.Pascal:return new mt;case St.Snake:return new bt;case St.ScreamingSnake:return new xt;default:throw new Error("No corresponding converter found")}}}]),t}(),Et=function(){function n(t,e){m(this,n),this.fromConverter=kt.getInstance(t),this.toConverter=kt.getInstance(e)}return T(n,[{key:"convert",value:function(t){return null==t||0===t.length?t:this.toConverter.to(this.fromConverter.from(t))}}]),n}(),Ot=lt(function(t,e){return new Et(t,e)},function(t,e){return t.toString()+e.toString()}),Tt=function(){function r(){m(this,r)}return T(r,null,[{key:"getConverter",value:function(t,e){return Ot(t,e)}},{key:"convert",value:function(t,e,n){return r.getConverter(t,e).convert(n)}}]),r}();var Lt=function u(c){for(var t=arguments.length,f=new Array(1<t?t-1:0),e=1;e<t;e++)f[e-1]=arguments[e];var n=f.filter(function(t){return t!==u._});if(n.length>=c.length)return c.apply(void 0,E(n));function r(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=new Set,o=0,i=f.map(function(t){return t!==u._||void 0===e[o]||e[o]===u._?t:(r.add(o),e[o++])}),a=e.filter(function(t,e){return!r.has(e)});return u.apply(void 0,[c].concat(E(i),E(a)))}return r.toString=function(){return"name: ".concat(c.name,", args: [").concat(f.map(function(t){return t.toString()}).join(", "),"]")},r._curry=!0,r};function Pt(t){return null==t}function Mt(t){return Pt(t)||""===t}Lt._=Symbol("_");var At=function(){function e(t){m(this,e),this.fmt=t}return T(e,[{key:"format",value:function(t){return Pt(t)?"":d(t,this.fmt)}},{key:"parse",value:function(t){return Mt(t)?null:U(t,this.fmt)}},{key:"strFormat",value:function(t,e){return Mt(t)?null:d(e?U(t,e):new Date(t),this.fmt)}}]),e}();At.dateFormatter=new At("yyyy-MM-dd"),At.timeFormatter=new At("hh:mm:ss"),At.dateTimeFormatter=new At("yyyy-MM-dd hh:mm:ss");var Rt=Symbol("TimoutInfinite").toString(),jt=function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=e.timeout,r=e.timeStart,o=e.serialize,i=e.deserialize;m(this,t),this.timeStart=r,this.timeout=n,this.serialize=o,this.deserialize=i};function Dt(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return R(e,function(t){return Pt(t)?[]:Object.entries(t)}).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return Pt(o)||(t[r]=o),t},{})}var Ct=function(){function e(t){m(this,e),this.cacheOption=Dt(new jt({timeout:Rt,serialize:JSON.stringify,deserialize:JSON.parse}),t)}return T(e,[{key:"add",value:function(t,e,n){}},{key:"del",value:function(t){}},{key:"set",value:function(t,e,n){}},{key:"get",value:function(t,e){}},{key:"touch",value:function(t,e){}}]),e}(),Ft=function t(e){var n=e.key,r=e.val,o=e.cacheOption;m(this,t),this.key=n,this.val=r,this.cacheOption=o},It=function(t){function n(t){var e;return m(this,n),(e=q(this,H(n).call(this,t))).localStorage=window.localStorage,e}return Z(n,Ct),T(n,[{key:"add",value:function(t,e,n){null===this.get(t,Dt({timeStart:Date.now()},n))&&this.set(t,e,n)}},{key:"del",value:function(t){this.localStorage.removeItem(t)}},{key:"set",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:new jt,r=Dt(this.cacheOption,{timeStart:Date.now()},n);this.localStorage.setItem(t,JSON.stringify(new Ft({key:t,val:r.serialize(e),cacheOption:r})))}},{key:"get",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new jt,n=this.localStorage.getItem(e),r=JSON.parse(n);if(null===r)return null;var o=Dt(this.cacheOption,r.cacheOption,t),i=o.timeStart,a=o.timeout,u=o.deserialize;if(a!==Rt&&Date.now()-i>a)return this.del(e),null;try{return u(r.val)}catch(t){return this.del(e),null}}},{key:"touch",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new jt,n=this.localStorage.getItem(e),r=JSON.parse(n);if(null===r)return null;var o=Dt(this.cacheOption,r.cacheOption,t),i=o.timeStart,a=o.timeout,u=o.deserialize;if(a!==Rt&&Date.now()-i>a)return this.del(e),null;try{var c=u(r.val);return this.set(e,c,Dt(o,{timeStart:Date.now()})),c}catch(t){return this.del(e),null}}}]),n}(),_t=new It,Ut=new(function(){function t(){m(this,t)}return T(t,[{key:"onceOfSameParam",value:function(u){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=t.identity,n=void 0===e?u.toString():e,r=t.timeout,c=void 0===r?Rt:r,f=function(t){return"onceOfSameParam-".concat(n,"-").concat(JSON.stringify(t))},o=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=f(e),o=new jt({timeout:c}),i=_t.get(r);if(null!==i)return i;var a=u.call.apply(u,[this].concat(e));return a instanceof Promise?a.then(function(t){return _t.set(r,t,o),t}):(_t.set(r,a,o),a)};return o.origin=u,o.clear=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=f(e);_t.del(r)},o}}]),t}()),Nt={cyclingDebugger:function(){setInterval(function(){},100)},checkDebug:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:function(){return window.location.reload()};setInterval(function(){var t=X(function(){for(var t=0;t<1e3;t++)console.log(t),console.clear()});500<t&&(console.log(t),e())},1e3)},disableConsoleOutput:function(){window.console||(window.console={});["log","debug","warn","info","dir","dirxml","trace","profile"].forEach(function(t){return console[t]=function(){}})}};t.DateFormatter=At,t.FetchLimiting=P,t.LocalStorageCache=It,t.StateMachine=V,t.StringStyleUtil=Tt,t.antiDebug=Nt,t.appends=function(t,e){for(var n in e)t.append(n,e[n]);return t},t.arrayDiffBy=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:z,r=new Set(t.map(n)),o=new Set(e.map(n)),i=t.filter(function(t){return!o.has(n(t))}),a=e.filter(function(t){return!r.has(n(t))}),u=new Set(i.map(n)),c=t.filter(function(t){return!u.has(n(t))});return new st(i,a,c)},t.arrayToMap=D,t.asIterator=M,t.asyncFlatMap=function(t,e){return A.apply(this,arguments)},t.autoIncrement=function(){return pt().next().value},t.blankToNull=nt,t.blankToNullField=function(t){var e={};for(var n in t){var r=t[n];e[n]="string"==typeof r?nt(r):r}return e},t.cacheUtil=Ut,t.compose=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduceRight(function(t,e){return function o(i,a){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=Lt.apply(void 0,[i].concat(e));return r instanceof Function&&!0===r._curry?o(r,a):Lt(a,r)}}(e,t)})},t.copyText=function(t){var e=document.createElement("input");document.body.appendChild(e),e.setAttribute("value",t),e.select();var n=document.execCommand("copy");return document.body.removeChild(e),n},t.createElByString=function(t){var e=document.createElement("div");return e.innerHTML=t,e.querySelector("*")},t.curry=Lt,t.dateBetween=function(t,e){return new ct(t,e)},t.dateConstants=ot,t.dateEnhance=function(t){return new ut(t)},t.dateFormat=d,t.dateParse=U,t.debounce=function(o,i){var a,u=2<arguments.length&&void 0!==arguments[2]?arguments[2]:void 0;return function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new Promise(function(t){a&&clearTimeout(a),a=setTimeout(function(){u=i.call.apply(i,[e].concat(n)),t(u)},o),setTimeout(function(){t(u)},o)})}},t.deepFreeze=function e(t){if(null!=t)return t instanceof Array?t.forEach(function(t){"object"===G(t)&&e(t)}):t instanceof Object&&Object.values(t).forEach(function(t){"object"===G(t)&&e(t)}),Object.freeze(t)},t.deepProxy=function(t){var r={get:function(t,e){Reflect.set(t,e,Reflect.has(t,e)?Reflect.get(t,e):{});var n=Reflect.get(t,e);return"object"===G(n)?new Proxy(n,r):n}};return new Proxy(t,r)},t.deletes=function(e,t){return t.forEach(function(t){return e.delete(t)}),e},t.download=i,t.downloadString=function(t){return n.apply(this,arguments)},t.downloadUrl=function(t){return r.apply(this,arguments)},t.emptyAllField=function(t){var e={};for(var n in t)e[n]=null;return e},t.excludeFields=rt,t.excludeFieldsDeep=function t(e){for(var n=arguments.length,r=new Array(1<n?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=e instanceof Array?e:rt.apply(void 0,[e].concat(r));for(var a in i)if(i.hasOwnProperty(a)){var u=i[a];u instanceof Object&&(e[a]=t.apply(void 0,[u].concat(r)))}return i},t.fetchTimeout=b,t.fill=C,t.filterItems=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:z,r=new Set(e.map(n));return t.filter(function(t){return!r.has(n(t))})},t.flatMap=R,t.formDataToArray=function(t){return M(t.entries())},t.format=function(t,n){return n?Object.keys(n).reduce(function(t,e){return t.replace(new RegExp("{".concat(e,"}"),"g"),n[e])},t):t},t.getCookies=function(){return document.cookie.split(";").map(function(t){return t.split("=")}).map(function(t){return[t[0].trim(),t[1].trim()]}).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return t.set(r,o)},new Map)},t.getCusorPostion=N,t.getYearWeek=function(t){var e=t.getTime()-new Date(t.getFullYear(),0,1).getTime();return Math.floor(e/864e5/7)},t.groupBy=j,t.insertText=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:N(t),r=t.value;t.value=r.substr(0,n)+e+r.substr(n),Y(t,n+e.length)},t.isBlank=function(t){return Mt(t)||""===t.trim()},t.isEditable=function(t){return t&&(t.isContentEditable||["input","date","datetime","select","textarea"].includes(B(t.tagName)))},t.isEmpty=Mt,t.isFloat=function(t){return tt.test(t)},t.isNullOrUndefined=Pt,t.isNumber=function(t){return et.test(t)},t.isRange=it,t.lastFocus=function(){return F},t.loadResource=function(t,e){return h.apply(this,arguments)},t.mapToObject=function(t){var e={},n=!0,r=!1,o=void 0;try{for(var i,a=t[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var u=s(i.value,2),c=u[0],f=u[1];e[c]=f}}catch(t){r=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return e},t.objToFormData=function(t){var e=new FormData;if(t)for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];e.append(n,r)}return e},t.once=ft,t.onceOfSameParam=lt,t.parseUrl=function(t){if(!t)throw new Error("url 不能为空");var e=new RegExp("^((\\w+)://([\\w\\.]*)(:(\\d+))?)(.*)").exec(t),n=new v({url:t,website:e[1],protocol:e[2],domain:e[3],port:e[5],href:e[6]}),r=t.substr(n.website.length),o=r.indexOf("?");return-1===o?n.accessPath=r:(n.accessPath=r.substr(0,o),n.accessPath.endsWith("/")&&(n.accessPath=n.accessPath.substring(0,n.accessPath.length-1)),n.port=n.port||p[n.protocol]||"",n.params=r.substr(o+1).split("&").map(function(t){return t.split("=")}).filter(function(t){return""!==t[0]}).reduce(function(t,e){var n=decodeURIComponent(e[0]),r=decodeURIComponent(1===e.length?"":e[1]),o=t[n];return void 0!==o?(Array.isArray(o)||(t[n]=[o]),t[n].push(r)):t[n]=r,t},{})),n},t.randomInt=function(){var t,e;if(0===arguments.length)throw new Error("非法参数,必须指定最大值");return 1===arguments.length?(t=0,e=arguments.length<=0?void 0:arguments[0]):1<arguments.length&&(t=arguments.length<=0?void 0:arguments[0],e=arguments.length<=1?void 0:arguments[1]),t+Math.floor(Math.random()*(e-t))},t.range=function(t,e){for(var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:1,r=[],o=t;o<e;o+=n)r.push(o);return r},t.readLocal=y,t.removeEl=function(t){return t.parentElement.removeChild(t)},t.removeText=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t.selectionStart,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:t.selectionEnd,r=N(t),o=t.value;t.value=o.substr(0,e)+o.substr(n,o.length),Y(t,r)},t.returnItself=z,t.returnReasonableItself=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.length;if(0!==r)return 1===r?e[0]:e},t.safeExec=$,t.setCusorPostion=Y,t.sets=function(t,e){for(var n in e)t.set(n,e[n]);return t},t.singleModel=K,t.sortBy=function t(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:z;if(e.length<=1)return e;var r=Math.floor(e.length/2),o=e.slice(),i=o.splice(r,1)[0],a=n(i),u=j(o,function(t){return n(t)<a});return[].concat(E(t(u.get(!0)||[],n)),[i],E(t(u.get(!1)||[],n)))},t.spliceParams=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(!(t instanceof Object))throw new Error("The parameter type must be Object: ".concat(t));return Array.from(Object.entries(t)).reduce(function(t,e){var n=s(e,2),r=n[0],o=n[1];return null==o?t:(o instanceof Date?t+=w(r,d(o,g)):o instanceof Array?t+=o.map(function(t){return w(r,t instanceof Date?d(t,g):t)}).join("&"):t+=w(r,o),t+"&")},"")},t.strToArrayBuffer=function(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),r=0;r!==t.length;++r)n[r]=255&t.charCodeAt(r);return e},t.strToDate=function(t,e){return U(t,e)},t.stringStyleType=St,t.throttle=function(o,i){var a,u=0;return function(){for(var n=this,t=arguments.length,r=new Array(t),e=0;e<t;e++)r[e]=arguments[e];return new Promise(function(t){var e=Date.now();if(o<e-u)return a=i.call.apply(i,[n].concat(r)),u=e,void t(a);t(a)})}},t.timing=X,t.toLowerCase=B,t.toObject=function(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:function(t){return t};return t.reduce(function(t,e){return t.hasOwnProperty(n(e))||(t[n(e)]=r(e)),t},{})},t.toString=function(t){return Pt(t)?"":t instanceof Date?t.toISOString():t.toString()},t.toUpperCase=function(t){return t&&"string"==typeof t?t.toUpperCase():t},t.uniqueBy=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(t){return JSON.stringify(t)},n={};return t.filter(function(t){return!n.hasOwnProperty(e(t))&&(n[e(t)]=!0)})},t.wait=L,t.waitResource=function(r){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=t.interval,o=void 0===e?100:e,n=t.max,i=void 0===n?10:n,a=0;return new Promise(function(t,e){var n=setInterval(function(){r()&&(clearInterval(n),t()),i<=++a&&(clearInterval(n),e(new Error("等待超时")))},o)})},t.watch=function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:100,r=$(e),o=setInterval(function(){var t=$(e);r!==t&&(n(t,r),r=t)},t);return function(){return clearInterval(o)}},t.watchEventListener=function(){var o=document.addEventListener,i=EventTarget.prototype.addEventListener,a=document.removeEventListener,u=EventTarget.prototype.removeEventListener,c=[],f=function t(e,n,r,o){m(this,t),this.el=e,this.type=n,this.listener=r,this.useCapture=o};function t(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],r=this===document?o:i;c.push(new f(this,t,e,n)),r.apply(this,arguments)}function e(t){var n=arguments,r=this,o=r===document?a:u,e=c.map(function(t,e){return t.el===r||t.type===n[0]?e:-1}).filter(function(t){return-1!==t});e.forEach(function(t){var e=c[t];o.apply(e.el,[e.type,e.listener,e.useCapture])}),e.sort(function(t,e){return e-t}).forEach(function(t){return c.splice(t,1)})}document.addEventListener=EventTarget.prototype.addEventListener=t,document.removeEventListenerByType=EventTarget.prototype.removeEventListenerByType=e},t.watchObject=function(t,o){var i={get:function(e,n,r){try{return new Proxy(e[n],i)}catch(t){return Reflect.get(e,n,r)}},set:function(t,e,n,r){return o(t,e,n),Reflect.set(t,e,n,r)}};return new Proxy(t,i)},Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=rx-util.min.js.map