rx-util

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

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

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/382120/691634/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 a=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 u(t,e,n,r){var i,u,a,c,o=e&&e.prototype instanceof g?e:g,f=Object.create(o.prototype),s=new O(r||[]);return f._invoke=(i=t,u=n,a=s,c=h,function(t,e){if(c===p)throw new Error("Generator is already running");if(c===y){if("throw"===t)throw e;return P()}for(a.method=t,a.arg=e;;){var n=a.delegate;if(n){var r=S(n,a);if(r){if(r===d)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(c===h)throw c=y,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);c=p;var o=l(i,u,a);if("normal"===o.type){if(c=a.done?y:v,o.arg===d)continue;return{value:o.arg,done:a.done}}"throw"===o.type&&(c=y,a.method="throw",a.arg=o.arg)}}),f}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}i.wrap=u;var h="suspendedStart",v="suspendedYield",p="executing",y="completed",d={};function g(){}function a(){}function s(){}var m={};m[o]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w(M([])));b&&b!==t&&f.call(b,o)&&(m=b);var x=s.prototype=g.prototype=Object.create(m);function E(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=l(c[t],c,n);if("throw"!==i.type){var u=i.arg,a=u.value;return a&&"object"==typeof a&&f.call(a,"__await")?Promise.resolve(a.__await).then(function(t){e("next",t,r,o)},function(t){e("throw",t,r,o)}):Promise.resolve(a).then(function(t){u.value=t,r(u)},function(t){return e("throw",t,r,o)})}o(i.arg)}(n,r,t,e)})}return e=e?e.then(t,t):t()}}function S(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,S(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=l(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 L(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 O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function M(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:P}}function P(){return{value:c,done:!0}}return a.prototype=x.constructor=s,s.constructor=a,s[r]=a.displayName="GeneratorFunction",i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===a||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,r in t||(t[r]="GeneratorFunction")),t.prototype=Object.create(x),t},i.awrap=function(t){return{__await:t}},E(k.prototype),k.prototype[n]=function(){return this},i.AsyncIterator=k,i.async=function(t,e,n,r){var o=new k(u(t,e,n,r));return i.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},E(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=M,O.prototype={constructor:O,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 u=f.call(o,"catchLoc"),a=f.call(o,"finallyLoc");if(u&&a){if(this.prev<o.catchLoc)return t(o.catchLoc,!0);if(this.prev<o.finallyLoc)return t(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return t(o.catchLoc,!0)}else{if(!a)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:M(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,u){try{var a=t[i](u),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,o)}var u=function(a){return function(){var t=this,u=arguments;return new Promise(function(e,n){var r=a.apply(t,u);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=u(a.mark(function t(e){var n,r=arguments;return a.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=u(a.mark(function t(e){var n,r,o=arguments;return a.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 u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n};var s=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var l=function(t,e){return o(t)||f(t,e)||s()};function h(){return(h=u(a.mark(function t(e,n){var r,o,i,u=arguments;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=2<u.length&&void 0!==u[2]?u[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,u=e.protocol,a=void 0===u?"":u,c=e.domain,f=void 0===c?"":c,s=e.accessPath,l=void 0===s?"":s,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=a,this.domain=f,this.accessPath=l,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 E=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 S=function(t){return x(t)||E(t)||k()};function L(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&&L(t.prototype,e),n&&L(t,n),t},O=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()})},M=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=u(a.mark(function t(e,n){var r,o=this,i=arguments;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=function(){var t=u(a.mark(function t(){var e;return a.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,S(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,O(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 P(t){for(var e=[];;){var n=t.next();if(n.done)break;e.push(n.value)}return e}function R(){return(R=u(a.mark(function t(e,n){var r,o;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:r=[],t.t0=a.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 A(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 j,D=function t(e,n,r,o){m(this,t),this.name=e,this.format=n,this.value=r,this.index=o},F={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}",milliSecond:"S{1,3}"};function _(o,t){var e={year:(new Date).getFullYear().toString(),month:"01",day:"01",hour:"00",minute:"00",second:"00",milliSecond:"000"},i=[];for(var n in F){var r=new RegExp(F[n]);if(r.test(t)){var u=r.exec(t)[0],a=C("`",u.length),c=t.indexOf(u);t=t.replace(u,a),i.push(new D(n,C("\\d",u.length),null,c))}else i.push(new D(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=A(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 s="".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("milliSecond"));return new Date(s)}function I(t){return t.selectionStart}function U(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e;t.focus(),t.setSelectionRange(e,n)}function Y(t){return t&&"string"==typeof t?t.toLowerCase():t}document.addEventListener("focus",function(t){j=t.target},!0),document.addEventListener("blur",function(){j=null},!0);function N(t){return t}var B=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}},$=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 G=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"!==$(e)&&"function"!=typeof e?G(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 J=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 Z(e){var u;return function(t){function i(){var t,e;if(m(this,i),u)return q(e,u);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))),u=G(e),e}return J(i,e),i}()}var z=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}),K=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,Z(e)),e}},{key:"getInstance",value:function(t){var e=n.get(t);return e?z(e,S(Array.from(arguments).slice(1))):null}}]),t}())}}]),t}();var Q=new RegExp("^(-?\\d+)(.\\d+)?$");var V=new RegExp("^-?\\d+$");function X(t){return t&&0!==t.trim().length?t:null}var tt=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 et(t,e,n){return e<=t&&t<n}var nt=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}()),rt=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:"dayOfYear",value:function(){return Math.floor((this.date.getTime()-nt.yearStart().getTime())/864e5)}},{key:"dayOfMonth",value:function(){return this.date.getDate()}},{key:"dayOfWeek",value:function(){return this.date.getDay()}},{key:"weekOfYear",value:function(){var t=this.dayOfYear();return Math.floor(t/7+(t%7==0?0:1))}},{key:"weekOfMonth",value:function(){var t=this.dayOfMonth();return Math.floor(t/7+(t%7==0?0:1))}},{key:"quarter",value:function(){var t=this.month();return et(t,0,3)?1:et(t,3,6)?2:et(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 ot=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 it=function(r){var o,i=!0;return function(){if(!1===i)return o;i=!1;for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return o=r.call.apply(r,[this].concat(e))}},ut=function(u){var a=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=a.apply(void 0,e),o=c.get(r);if(void 0!==o)return o;var i=u.call.apply(u,[this].concat(e));return i instanceof Promise?i.then(function(t){return c.set(r,t),t}):(c.set(r,i),i)}};var at=function t(e,n,r){m(this,t),this.left=e,this.right=n,this.common=r};var ct=a.mark(ft);function ft(){var e;return a.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()}},ct)}var st=it(ft);var lt=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}(),ht=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return J(e,lt),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}(),vt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return J(e,ht),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}(),pt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return J(e,ht),T(e,[{key:"to",value:function(t){return t.map(function(t){return t.substring(0,1).toUpperCase()+t.substring(1)}).join()}}]),e}(),yt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return J(e,lt),T(e,[{key:"from",value:function(t){return t.split("_")}}]),e}(),dt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return J(e,yt),T(e,[{key:"to",value:function(t){return t.map(function(t){return t.toLowerCase()}).join("_")}}]),e}(),gt=function(t){function e(){return m(this,e),q(this,H(e).apply(this,arguments))}return J(e,yt),T(e,[{key:"to",value:function(t){return t.map(function(t){return t.toUpperCase()}).join("_")}}]),e}(),mt={Camel:Symbol(1),Pascal:Symbol(2),Snake:Symbol(3),ScreamingSnake:Symbol(4)},wt=function(){function t(){m(this,t)}return T(t,null,[{key:"getInstance",value:function(t){switch(t){case mt.Camel:return new vt;case mt.Pascal:return new pt;case mt.Snake:return new dt;case mt.ScreamingSnake:return new gt;default:throw new Error("No corresponding converter found")}}}]),t}(),bt=function(){function n(t,e){m(this,n),this.fromConverter=wt.getInstance(t),this.toConverter=wt.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}(),xt=ut(function(t,e){return new bt(t,e)},function(t,e){return t.toString()+e.toString()}),Et=function(){function r(){m(this,r)}return T(r,null,[{key:"getConverter",value:function(t,e){return xt(t,e)}},{key:"convert",value:function(t,e,n){return r.getConverter(t,e).convert(n)}}]),r}();t.FetchLimiting=M,t.StateMachine=K,t.StringStyleUtil=Et,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]:N,r=new Set(t.map(n)),o=new Set(e.map(n)),i=t.filter(function(t){return!o.has(n(t))}),u=e.filter(function(t){return!r.has(n(t))}),a=new Set(i.map(n)),c=t.filter(function(t){return!a.has(n(t))});return new at(i,u,c)},t.arrayToMap=A,t.asIterator=P,t.asyncFlatMap=function(t,e){return R.apply(this,arguments)},t.autoIncrement=function(){return st().next().value},t.blankToNull=X,t.blankToNullField=function(t){var e={};for(var n in t){var r=t[n];e[n]="string"==typeof r?X(r):r}return e},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.dateBetween=function(t,e){return new ot(t,e)},t.dateConstants=tt,t.dateEnhance=function(t){return new rt(t)},t.dateFormat=d,t.dateParse=_,t.debounce=function(o,i){var u;return function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];u&&clearTimeout(u),u=setTimeout(function(){i.call.apply(i,[t].concat(n))},o)}},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=function(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=l(e,2),r=n[0],o=n[1];return i.has(r)||(t[r]=o),t},{})},t.fetchTimeout=b,t.fill=C,t.filterItems=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:N,r=new Set(e.map(n));return t.filter(function(t){return!r.has(n(t))})},t.flatMap=function(t,n){return t.reduce(function(t,e){return t.concat(n(e))},[])},t.formDataToArray=function(t){return P(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=l(e,2),r=n[0],o=n[1];return t.set(r,o)},new Map)},t.getCusorPostion=I,t.getYearWeek=function(t){var e=t.getTime()-new Date(t.getFullYear(),0,1).getTime();return Math.floor(e/864e5/7)},t.groupBy=function(t,r){return t.reduce(function(t,e){var n=r(e);return t.has(n)||t.set(n,[]),t.get(n).push(e),t},new Map)},t.insertText=function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:I(t),r=t.value;t.value=r.substr(0,n)+e+r.substr(n),U(t,n+e.length)},t.isEditable=function(t){return t&&(t.isContentEditable||["input","date","datetime","select","textarea"].includes(Y(t.tagName)))},t.isFloat=function(t){return Q.test(t)},t.isNumber=function(t){return V.test(t)},t.isRange=et,t.lastFocus=function(){return j},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,u=t[Symbol.iterator]();!(n=(i=u.next()).done);n=!0){var a=l(i.value,2),c=a[0],f=a[1];e[c]=f}}catch(t){r=!0,o=t}finally{try{n||null==u.return||u.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.onec=it,t.onecOfSameParam=ut,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=I(t),o=t.value;t.value=o.substr(0,e)+o.substr(n,o.length),U(t,r)},t.returnItself=N,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=B,t.setCusorPostion=U,t.sets=function(t,e){for(var n in e)t.set(n,e[n]);return t},t.singleModel=Z,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=l(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 _(t,e)},t.stringStyleType=mt,t.throttle=function(e,n){var r=0;return function(){var t=Date.now();e<t-r&&(n.apply(this,arguments),r=t)}},t.timing=function(t){var e=performance.now(),n=t();return n instanceof Promise?n.then(function(){return performance.now()-e}):performance.now()-e},t.toLowerCase=Y,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.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=O,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,u=0;return new Promise(function(t,e){var n=setInterval(function(){r()&&(clearInterval(n),t()),i<=++u&&(clearInterval(n),e(new Error("等待超时")))},o)})},t.watch=function(e,n){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:100,r=B(e),o=setInterval(function(){var t=B(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,u=document.removeEventListener,a=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?u:a,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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址