utils-uniapp 1.2.14 → 1.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../_rollupPluginBabelHelpers-3cc6d021.js");var d={create:function(t){return new WebSocket(t)},bind:function(t,e){t.onopen=e.open,t.onmessage=e.message,t.onclose=e.close,t.onerror=e.error},unbind:function(t){t.onopen=t.onmessage=t.onclose=t.onerror=null},send:function(t,e){t.send(e)},close:function(t,e,n){t.close(e,n)}},u={create:function(t){var e=wx.connectSocket({url:t});if(!e||typeof e.onOpen!="function")throw new Error("wx.connectSocket did not return a valid SocketTask");return e},bind:function(t,e){t.onOpen(e.open),t.onMessage(e.message),t.onClose(e.close),t.onError(e.error)},unbind:function(){},send:function(t,e){t.send({data:e})},close:function(t,e,n){e!=null?t.close({code:e,reason:n||""}):t.close({})}},l=function(){function s(t){var e,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;c._classCallCheck(this,s),this.url=t,this.adapter=r.adapter||o||(typeof wx!="undefined"?u:d),this.reconnectDelay=r.reconnectDelay||1e3,this.maxReconnectDelay=r.maxReconnectDelay||3e4,this.backoffFactor=r.backoffFactor||2,this.jitter=(e=r.jitter)!==null&&e!==void 0?e:.3,this.maxReconnect=(n=r.maxReconnect)!==null&&n!==void 0?n:-1,this.stablePeriod=r.stablePeriod||60*1e3,this.maxDrops=r.maxDrops||5,this.heartbeatInterval=r.heartbeatInterval||3e4,this.heartbeatTimeout=r.heartbeatTimeout||1e4,this.heartbeatMsg=r.heartbeatMsg||"ping",this.connectTimeout=r.connectTimeout||15e3,this.transport=null,this.isConnected=!1,this.manualClose=!1,this.heartbeatTimer=null,this.heartbeatTimeoutTimer=null,this.reconnectTimer=null,this.connectTimeoutTimer=null,this.reconnectCount=0,this.dropCount=0,this.lastDropTime=0,this.connectedAt=0,this.dropCycle=0,this.handledCycle=0,this.events={open:[],message:[],close:[],error:[],reconnect:[],reconnecting:[],fail:[]}}return c._createClass(s,[{key:"on",value:function(e,n){return this.events[e]&&this.events[e].push(n),this}},{key:"off",value:function(e,n){if(!this.events[e])return this;var r=this.events[e],o=r.findIndex(function(i){return i===n||i._origin===n});return o>-1&&r.splice(o,1),this}},{key:"once",value:function(e,n){var r,o=this;if(!((r=this.events[e])!==null&&r!==void 0&&r.some(function(a){return a===n||a._origin===n}))){var i=function(){o.off(e,i),n.apply(void 0,arguments)};i._origin=n,this.on(e,i)}return this}},{key:"emit",value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];this.events[e]&&this.events[e].forEach(function(i){try{i.apply(void 0,r)}catch(a){console.error("[".concat(e,"] callback error:"),a)}})}},{key:"addEventListener",value:function(e,n){return this.on(e,n)}},{key:"removeEventListener",value:function(e,n){return this.off(e,n)}},{key:"connect",value:function(){var e=this;if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.clearConnectTimeout(),this.transport){var n=this.transport;this.transport=null,this.isConnected=!1,this.stopHeartbeat(),this.adapter.unbind(n);try{this.adapter.close(n,1e3,"reconnect")}catch(i){}}this.manualClose=!1;var r=this.dropCycle=this.dropCycle+1,o;try{o=this.adapter.create(this.url)}catch(i){return this.handleDrop(r,{type:"connectError",url:this.url,event:i}),this}if(o==null)return this.handleDrop(r,{type:"connectError",url:this.url,event:new Error("adapter.create returned no transport")}),this;this.transport=o,this.connectTimeoutTimer=setTimeout(function(){if(!(o!==e.transport||e.isConnected||e.manualClose)){console.warn("Connect timeout"),e.handleDrop(r,{type:"connectTimeout",url:e.url});try{e.adapter.close(o)}catch(i){}}},this.connectTimeout);try{this.adapter.bind(o,{open:function(a){if(o===e.transport&&!e.manualClose){e.clearConnectTimeout(),e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null),e.handledCycle===r&&(e.handledCycle=0);var h=e.reconnectCount>0;e.isConnected=!0,e.connectedAt=Date.now(),e.reconnectCount=0,console.log("Connection established"),e.emit("open",a),h&&(console.log("Reconnected successfully"),e.emit("reconnect",a)),e.startHeartbeat()}},message:function(a){o===e.transport&&(e.clearHeartbeatTimeout(),e.emit("message",a))},close:function(a){o===e.transport&&(e.clearConnectTimeout(),e.isConnected=!1,e.stopHeartbeat(),e.transport=null,console.log("Connection closed"),e.emit("close",a),!e.manualClose&&e.handleDrop(r))},error:function(a){if(o===e.transport){e.clearConnectTimeout(),console.error("WebSocket error:",a),e.emit("error",a),e.isConnected=!1,e.stopHeartbeat(),e.manualClose||e.handleDrop(r,{type:"connectError",url:e.url,event:a});try{e.adapter.close(o,1e3,"error")}catch(h){}}}})}catch(i){this.clearConnectTimeout(),this.transport=null;try{this.adapter.close(o)}catch(a){}return this.handleDrop(r,{type:"connectError",url:this.url,event:i}),this}return this}},{key:"handleDrop",value:function(e,n){if(!this.manualClose&&e===this.dropCycle&&this.handledCycle!==e){this.handledCycle=e;var r=this.connectedAt>0,o=r?Date.now()-this.connectedAt:0;if(this.connectedAt=0,r&&(o>=this.stablePeriod&&(this.dropCount=0),this.dropCount++,this.lastDropTime=Date.now(),console.warn("Drop #".concat(this.dropCount," (uptime ").concat((o/1e3).toFixed(1),"s)")),this.dropCount>this.maxDrops)){this.emit("fail",{type:"tooManyDrops",dropCount:this.dropCount,stablePeriod:this.stablePeriod,willRetry:!1}),this.dropCount=0;return}var i=this.reconnect();n&&this.emit("fail",c._objectSpread2(c._objectSpread2({},n),{},{willRetry:i}))}}},{key:"reconnect",value:function(){var e=this;if(this.isConnected||this.reconnectTimer)return!1;if(this.maxReconnect!==-1&&this.reconnectCount>=this.maxReconnect)return console.log("已到达最大重连次数(".concat(this.maxReconnect,"),停止重连")),this.emit("fail",{type:"maxReconnect",maxReconnect:this.maxReconnect,url:this.url,willRetry:!1}),!1;var n=this.getBackoffDelay();return this.reconnectCount+=1,console.log("Reconnecting in ".concat((n/1e3).toFixed(1),"s... count:").concat(this.reconnectCount)),this.emit("reconnecting",{delay:n,count:this.reconnectCount}),this.reconnectTimer=setTimeout(function(){e.reconnectTimer=null,e.connect()},n),!0}},{key:"getBackoffDelay",value:function(){var e=Math.max(this.reconnectCount,0),n=this.reconnectDelay*Math.pow(this.backoffFactor,e);return n=Math.min(n,this.maxReconnectDelay),this.jitter>0&&(n+=(Math.random()*2-1)*n*this.jitter),Math.max(Math.round(n),100)}},{key:"send",value:function(e){return this.isConnected&&this.transport?this.adapter.send(this.transport,e):console.error("WebSocket is not connected"),this}},{key:"startHeartbeat",value:function(){var e=this;this.stopHeartbeat(),this.heartbeatTimer=setInterval(function(){e.isConnected&&(e.send(e.heartbeatMsg),e.startHeartbeatTimeout())},this.heartbeatInterval)}},{key:"stopHeartbeat",value:function(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.clearHeartbeatTimeout()}},{key:"startHeartbeatTimeout",value:function(){var e=this;this.clearHeartbeatTimeout();var n=this.transport;this.heartbeatTimeoutTimer=setTimeout(function(){if(!(n!==e.transport||!e.isConnected)){console.warn("Heartbeat timeout, connection dead"),e.isConnected=!1,e.stopHeartbeat(),e.handleDrop(e.dropCycle,{type:"heartbeatTimeout"});try{e.adapter.close(n,1e3,"heartbeat")}catch(r){}}},this.heartbeatTimeout)}},{key:"clearHeartbeatTimeout",value:function(){this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null)}},{key:"clearConnectTimeout",value:function(){this.connectTimeoutTimer&&(clearTimeout(this.connectTimeoutTimer),this.connectTimeoutTimer=null)}},{key:"close",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e3,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(this.manualClose=!0,this.isConnected=!1,this.stopHeartbeat(),this.clearConnectTimeout(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectCount=0,this.dropCount=0,this.connectedAt=0,this.dropCycle=this.dropCycle+1,this.transport)try{this.adapter.close(this.transport,e,n)}catch(r){try{this.adapter.close(this.transport)}catch(o){}}}},{key:"getStats",value:function(){return{connected:this.isConnected,reconnectCount:this.reconnectCount,dropCount:this.dropCount,lastDropTime:this.lastDropTime,uptime:this.isConnected?Date.now()-this.connectedAt:0}}}])}(),m=function(s){function t(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return c._classCallCheck(this,t),c._callSuper(this,t,[e,n,u])}return c._inherits(t,s),c._createClass(t)}(l);exports.BrowserWebSocketAdapter=d;exports.UniWebSocketAdapter=u;exports.UniWebSocketClient=m;exports.WebSocketClient=l;exports.default=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../_rollupPluginBabelHelpers-3cc6d021.js");var m={create:function(t){return new WebSocket(t)},bind:function(t,e){t.onopen=e.open,t.onmessage=e.message,t.onclose=e.close,t.onerror=e.error},unbind:function(t){t.onopen=t.onmessage=t.onclose=t.onerror=null},send:function(t,e){t.send(e)},close:function(t,e,n){t.close(e,n)}},u={create:function(t){var e=uni.connectSocket({url:t,complete:function(){}});if(!e||typeof e.onOpen!="function")throw new Error("uni.connectSocket did not return a valid SocketTask");return e},bind:function(t,e){t.onOpen(e.open),t.onMessage(e.message),t.onClose(e.close),t.onError(e.error)},unbind:function(){},send:function(t,e){t.send({data:e})},close:function(t,e,n){e!=null?t.close({code:e,reason:n||""}):t.close({})}},l=function(){function s(t){var e,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;c._classCallCheck(this,s),this.url=t,this.adapter=r.adapter||o||(typeof uni!="undefined"?u:m),this.reconnectDelay=r.reconnectDelay||1e3,this.maxReconnectDelay=r.maxReconnectDelay||3e4,this.backoffFactor=r.backoffFactor||2,this.jitter=(e=r.jitter)!==null&&e!==void 0?e:.3,this.maxReconnect=(n=r.maxReconnect)!==null&&n!==void 0?n:-1,this.stablePeriod=r.stablePeriod||60*1e3,this.maxDrops=r.maxDrops||5,this.heartbeatInterval=r.heartbeatInterval||3e4,this.heartbeatTimeout=r.heartbeatTimeout||1e4,this.heartbeatMsg=r.heartbeatMsg||"ping",this.connectTimeout=r.connectTimeout||15e3,this.transport=null,this.isConnected=!1,this.manualClose=!1,this.heartbeatTimer=null,this.heartbeatTimeoutTimer=null,this.reconnectTimer=null,this.connectTimeoutTimer=null,this.reconnectCount=0,this.dropCount=0,this.lastDropTime=0,this.connectedAt=0,this.dropCycle=0,this.handledCycle=0,this.events={open:[],message:[],close:[],error:[],reconnect:[],reconnecting:[],fail:[]}}return c._createClass(s,[{key:"on",value:function(e,n){return this.events[e]&&this.events[e].push(n),this}},{key:"off",value:function(e,n){if(!this.events[e])return this;var r=this.events[e],o=r.findIndex(function(i){return i===n||i._origin===n});return o>-1&&r.splice(o,1),this}},{key:"once",value:function(e,n){var r,o=this;if(!((r=this.events[e])!==null&&r!==void 0&&r.some(function(a){return a===n||a._origin===n}))){var i=function(){o.off(e,i),n.apply(void 0,arguments)};i._origin=n,this.on(e,i)}return this}},{key:"emit",value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];this.events[e]&&this.events[e].forEach(function(i){try{i.apply(void 0,r)}catch(a){console.error("[".concat(e,"] callback error:"),a)}})}},{key:"addEventListener",value:function(e,n){return this.on(e,n)}},{key:"removeEventListener",value:function(e,n){return this.off(e,n)}},{key:"connect",value:function(){var e=this;if(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.clearConnectTimeout(),this.transport){var n=this.transport;this.transport=null,this.isConnected=!1,this.stopHeartbeat(),this.adapter.unbind(n);try{this.adapter.close(n,1e3,"reconnect")}catch(i){}}this.manualClose=!1;var r=this.dropCycle=this.dropCycle+1,o;try{o=this.adapter.create(this.url)}catch(i){return this.handleDrop(r,{type:"connectError",url:this.url,event:i}),this}if(o==null)return this.handleDrop(r,{type:"connectError",url:this.url,event:new Error("adapter.create returned no transport")}),this;this.transport=o,this.connectTimeoutTimer=setTimeout(function(){if(!(o!==e.transport||e.isConnected||e.manualClose)){console.warn("Connect timeout"),e.handleDrop(r,{type:"connectTimeout",url:e.url});try{e.adapter.close(o)}catch(i){}}},this.connectTimeout);try{this.adapter.bind(o,{open:function(a){if(o===e.transport&&!e.manualClose){e.clearConnectTimeout(),e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null),e.handledCycle===r&&(e.handledCycle=0);var h=e.reconnectCount>0;e.isConnected=!0,e.connectedAt=Date.now(),e.reconnectCount=0,console.log("Connection established"),e.emit("open",a),h&&(console.log("Reconnected successfully"),e.emit("reconnect",a)),e.startHeartbeat()}},message:function(a){o===e.transport&&(e.clearHeartbeatTimeout(),e.emit("message",a))},close:function(a){o===e.transport&&(e.clearConnectTimeout(),e.isConnected=!1,e.stopHeartbeat(),e.transport=null,console.log("Connection closed"),e.emit("close",a),!e.manualClose&&e.handleDrop(r))},error:function(a){if(o===e.transport){e.clearConnectTimeout(),console.error("WebSocket error:",a),e.emit("error",a),e.isConnected=!1,e.stopHeartbeat(),e.manualClose||e.handleDrop(r,{type:"connectError",url:e.url,event:a});try{e.adapter.close(o,1e3,"error")}catch(h){}}}})}catch(i){this.clearConnectTimeout(),this.transport=null;try{this.adapter.close(o)}catch(a){}return this.handleDrop(r,{type:"connectError",url:this.url,event:i}),this}return this}},{key:"handleDrop",value:function(e,n){if(!this.manualClose&&e===this.dropCycle&&this.handledCycle!==e){this.handledCycle=e;var r=this.connectedAt>0,o=r?Date.now()-this.connectedAt:0;if(this.connectedAt=0,r&&(o>=this.stablePeriod&&(this.dropCount=0),this.dropCount++,this.lastDropTime=Date.now(),console.warn("Drop #".concat(this.dropCount," (uptime ").concat((o/1e3).toFixed(1),"s)")),this.dropCount>this.maxDrops)){this.emit("fail",{type:"tooManyDrops",dropCount:this.dropCount,stablePeriod:this.stablePeriod,willRetry:!1}),this.dropCount=0;return}var i=this.reconnect();n&&this.emit("fail",c._objectSpread2(c._objectSpread2({},n),{},{willRetry:i}))}}},{key:"reconnect",value:function(){var e=this;if(this.isConnected||this.reconnectTimer)return!1;if(this.maxReconnect!==-1&&this.reconnectCount>=this.maxReconnect)return console.log("已到达最大重连次数(".concat(this.maxReconnect,"),停止重连")),this.emit("fail",{type:"maxReconnect",maxReconnect:this.maxReconnect,url:this.url,willRetry:!1}),!1;var n=this.getBackoffDelay();return this.reconnectCount+=1,console.log("Reconnecting in ".concat((n/1e3).toFixed(1),"s... count:").concat(this.reconnectCount)),this.emit("reconnecting",{delay:n,count:this.reconnectCount}),this.reconnectTimer=setTimeout(function(){e.reconnectTimer=null,e.connect()},n),!0}},{key:"getBackoffDelay",value:function(){var e=Math.max(this.reconnectCount,0),n=this.reconnectDelay*Math.pow(this.backoffFactor,e);return n=Math.min(n,this.maxReconnectDelay),this.jitter>0&&(n+=(Math.random()*2-1)*n*this.jitter),Math.max(Math.round(n),100)}},{key:"send",value:function(e){return this.isConnected&&this.transport?this.adapter.send(this.transport,e):console.error("WebSocket is not connected"),this}},{key:"startHeartbeat",value:function(){var e=this;this.stopHeartbeat(),this.heartbeatTimer=setInterval(function(){e.isConnected&&(e.send(e.heartbeatMsg),e.startHeartbeatTimeout())},this.heartbeatInterval)}},{key:"stopHeartbeat",value:function(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.clearHeartbeatTimeout()}},{key:"startHeartbeatTimeout",value:function(){var e=this;this.clearHeartbeatTimeout();var n=this.transport;this.heartbeatTimeoutTimer=setTimeout(function(){if(!(n!==e.transport||!e.isConnected)){console.warn("Heartbeat timeout, connection dead"),e.isConnected=!1,e.stopHeartbeat(),e.handleDrop(e.dropCycle,{type:"heartbeatTimeout"});try{e.adapter.close(n,1e3,"heartbeat")}catch(r){}}},this.heartbeatTimeout)}},{key:"clearHeartbeatTimeout",value:function(){this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null)}},{key:"clearConnectTimeout",value:function(){this.connectTimeoutTimer&&(clearTimeout(this.connectTimeoutTimer),this.connectTimeoutTimer=null)}},{key:"close",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e3,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(this.manualClose=!0,this.isConnected=!1,this.stopHeartbeat(),this.clearConnectTimeout(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectCount=0,this.dropCount=0,this.connectedAt=0,this.dropCycle=this.dropCycle+1,this.transport)try{this.adapter.close(this.transport,e,n)}catch(r){try{this.adapter.close(this.transport)}catch(o){}}}},{key:"getStats",value:function(){return{connected:this.isConnected,reconnectCount:this.reconnectCount,dropCount:this.dropCount,lastDropTime:this.lastDropTime,uptime:this.isConnected?Date.now()-this.connectedAt:0}}}])}(),d=function(s){function t(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return c._classCallCheck(this,t),c._callSuper(this,t,[e,n,u])}return c._inherits(t,s),c._createClass(t)}(l);exports.BrowserWebSocketAdapter=m;exports.UniWebSocketAdapter=u;exports.UniWebSocketClient=d;exports.WebSocketClient=l;exports.default=l;
@@ -98,6 +98,8 @@ export type SearchParams = Record<string, string | string[]>;
98
98
  export interface GetQueryParamsOptions {
99
99
  /** 是否静默模式,不输出警告 */
100
100
  silent?: boolean;
101
+ /** 是否解码,默认true */
102
+ decode?: boolean;
101
103
  /** 是否将 + 号解码为空格 */
102
104
  decodePlus?: boolean;
103
105
  /** 严格模式,解码失败时跳过该参数 */
@@ -170,6 +172,8 @@ export type ArrayFormatType = 'indices' | 'brackets' | 'repeat' | 'comma';
170
172
  export interface ToQueryStringOptions {
171
173
  /** 是否前置 ? */
172
174
  addQuestionMark?: boolean;
175
+ /** 是否编码,默认true */
176
+ encode?: boolean;
173
177
  /** 数组格式化模式,默认 comma */
174
178
  arrayFormat?: ArrayFormatType;
175
179
  /** true:空数组输出key=;false:空数组直接丢弃,默认 false */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../_rollupPluginBabelHelpers-3cc6d021.js");function M(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("compose 参数必须是函数");return t.length===0?function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.length===1?n[0]:n}:t.reduce(function(r,n){return function(){for(var a=this,i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return n.call.apply(n,[this,function(){for(var s=arguments.length,m=new Array(s),h=0;h<s;h++)m[h]=arguments[h];return r.apply(a,m.concat(c))}].concat(c))}},function(r){return r})}function Q(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("composeAsync 参数必须是函数");return t.length===0?l._asyncToGenerator(l._regenerator().m(function r(){var n,a,i,c=arguments;return l._regenerator().w(function(u){for(;;)switch(u.n){case 0:for(n=c.length,a=new Array(n),i=0;i<n;i++)a[i]=c[i];return u.a(2,a.length===1?a[0]:a)}},r)})):t.reduce(function(r,n){return l._asyncToGenerator(l._regenerator().m(function a(){var i=this,c,u,s,m=arguments;return l._regenerator().w(function(h){for(;;)switch(h.n){case 0:for(c=m.length,u=new Array(c),s=0;s<c;s++)u[s]=m[s];return h.a(2,n.call.apply(n,[this,l._asyncToGenerator(l._regenerator().m(function w(){var v,g,f,p=arguments;return l._regenerator().w(function(d){for(;;)switch(d.n){case 0:for(v=p.length,g=new Array(v),f=0;f<v;f++)g[f]=p[f];return d.a(2,r.apply(i,g.concat(u)))}},w)}))].concat(u)))}},a,this)}))},function(){var r=l._asyncToGenerator(l._regenerator().m(function n(a){return l._regenerator().w(function(i){for(;;)switch(i.n){case 0:return i.a(2,a)}},n)}));return function(n){return r.apply(this,arguments)}}())}function j(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("pipe 参数必须是函数");return t.length===0?function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.length===1?n[0]:n}:t.reverse().reduce(function(r,n){return function(){for(var a=this,i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return n.call.apply(n,[this,function(){for(var s=arguments.length,m=new Array(s),h=0;h<s;h++)m[h]=arguments[h];return r.apply(a,m.concat(c))}].concat(c))}},function(r){return r})}function O(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("pipeAsync 参数必须是函数");return t.length===0?l._asyncToGenerator(l._regenerator().m(function r(){var n,a,i,c=arguments;return l._regenerator().w(function(u){for(;;)switch(u.n){case 0:for(n=c.length,a=new Array(n),i=0;i<n;i++)a[i]=c[i];return u.a(2,a.length===1?a[0]:a)}},r)})):t.reverse().reduce(function(r,n){return l._asyncToGenerator(l._regenerator().m(function a(){var i=this,c,u,s,m=arguments;return l._regenerator().w(function(h){for(;;)switch(h.n){case 0:for(c=m.length,u=new Array(c),s=0;s<c;s++)u[s]=m[s];return h.a(2,n.call.apply(n,[this,l._asyncToGenerator(l._regenerator().m(function w(){var v,g,f,p=arguments;return l._regenerator().w(function(d){for(;;)switch(d.n){case 0:for(v=p.length,g=new Array(v),f=0;f<v;f++)g[f]=p[f];return d.a(2,r.apply(i,g.concat(u)))}},w)}))].concat(u)))}},a,this)}))},function(){var r=l._asyncToGenerator(l._regenerator().m(function n(a){return l._regenerator().w(function(i){for(;;)switch(i.n){case 0:return i.a(2,a)}},n)}));return function(n){return r.apply(this,arguments)}}())}function F(e,t){var o=null;r.stop=function(){return o&&clearTimeout(o)};function r(){for(var n=this,a=arguments.length,i=new Array(a),c=0;c<a;c++)i[c]=arguments[c];return r.stop(),o=setTimeout(function(){e.apply(n,i)},t),o}return r}function G(e,t){var o=null,r=[];n.stop=function(){if(o){var a;(a=r.shift())===null||a===void 0||a("cancel"),clearTimeout(o)}};function n(){for(var a=this,i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return new Promise(function(s,m){n.stop(),r.push(m),o=setTimeout(function(){s(e.apply(a,c))},t)})}return n}function _(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:500,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r,n,a=o?function(){if(!n){n=!0;for(var i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return typeof e=="function"&&e.apply(this,c),r=setTimeout(function(){n=!1},t),r}}:function(){for(var i=this,c=arguments.length,u=new Array(c),s=0;s<c;s++)u[s]=arguments[s];if(!n)return n=!0,r=setTimeout(function(){n=!1,typeof e=="function"&&e.apply(i,u)},t),r};return a.stop=function(){return r&&clearTimeout(r)},a}function $(e){return encodeURIComponent(JSON.stringify(e||{}))}function H(e){return JSON.parse(decodeURIComponent(e||"{}"))}function R(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t.silent,r=o===void 0?!1:o,n=t.decodePlus,a=n===void 0?!0:n,i=t.strict,c=i===void 0?!1:i,u={};if(typeof e!="string")return u;function s(U,I){var A=U;a&&(A=A.replace(/\+/g," "));try{return decodeURIComponent(A)}catch(E){return r||console.warn("Failed to decode ".concat(I?"key":"value",": ").concat(A),E),c?null:(I&&(A=A.replace(/%[0-9a-f]{2}/gi,"")),A)}}var m=e.split("#")[0],h=m.indexOf("?"),w=h>=0?m.slice(h+1):m;if(!w)return u;for(var v=w.split("&"),g=0;g<v.length;g++){var f=v[g];if(f){var p=f.indexOf("="),d=void 0,P=void 0;p===-1?(d=f,P=""):(d=f.slice(0,p),P=f.slice(p+1));var y=s(d,!0);if(!(y===null||!y)){var S=s(P,!1);if(S!==null){var T=y,b=!1;/\[\]$/.test(y)?(T=y.slice(0,-2),b=!0):/^(.+)\[\d+\]$/.test(y)&&(T=y.replace(/\[\d+\]$/,""),b=!0);var C=u[T];C===void 0?u[T]=b?[S]:S:Array.isArray(C)?C.push(S):u[T]=[C,S]}}}}return u}function L(e){return typeof window=="undefined"?{}:R(window.location.search,e)}function J(e){if(typeof window=="undefined")return{};var t=window.location.hash,o=t.indexOf("?");if(o===-1)return{};var r=t.substring(o);return R(r,e)}function q(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"-";return[Date.now().toString(),Math.random().toString(16).slice(2,10),Math.random().toString(16).slice(7),e.toString()].join(t)}function B(e){return e.replace(/([^-])([^-]*)/g,function(t,o,r){return o.toLocaleUpperCase()+r.toLocaleLowerCase()}).replace(/-/g,"")}function D(e,t){e=e.split("."),t=t.split(".");for(var o=Math.max(e.length,t.length);e.length<o;)e.push("0");for(;t.length<o;)t.push("0");for(var r=0;r<o;r++){var n=parseInt(e[r]),a=parseInt(t[r]);if(n>a)return 1;if(n<a)return-1}return 0}function N(){return"#"+Math.floor(Math.random()*16777215).toString(16).padEnd(6,"0")}function z(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:8,t=arguments.length>1?arguments[1]:void 0;e=e||32,t||(t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678");for(var o=t.length,r="",n=0;n<e;n++)r+=t.charAt(Math.floor(Math.random()*o));return r}function V(e){var t,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e||l._typeof(e)!=="object")return"";var r=o.addQuestionMark,n=r===void 0?!1:r,a=o.arrayFormat,i=a===void 0?"comma":a,c=o.keepEmptyArray,u=c===void 0?!1:c,s=[],m={indices:function(g,f){f.forEach(function(p,d){s.push("".concat(g,"[").concat(d,"]=").concat(encodeURIComponent(p)))})},brackets:function(g,f){f.forEach(function(p){s.push("".concat(g,"[]=").concat(encodeURIComponent(p)))})},repeat:function(g,f){f.forEach(function(p){s.push("".concat(g,"=").concat(encodeURIComponent(p)))})},comma:function(g,f){var p=f.map(function(d){return encodeURIComponent(d)}).join(",");s.push("".concat(g,"=").concat(p))}},h=(t=m[i])!==null&&t!==void 0?t:m.comma;Object.keys(e).forEach(function(v){var g=e[v];if(g!=null){var f=encodeURIComponent(v);if(Array.isArray(g)){var p=g.filter(function(P){return P!=null});if(p.length===0){u&&s.push("".concat(f,"="));return}h(f,p);return}var d=g;l._typeof(d)==="object"&&d!==null&&(d=JSON.stringify(d)),s.push("".concat(f,"=").concat(encodeURIComponent(d)))}});var w=s.join("&");return n&&w?"?".concat(w):w}function W(e){var t=e.scene;return t&&(e=l._objectSpread2(l._objectSpread2({fromCode:!0},e),R(t))),e}exports.compareVersion=D;exports.compose=M;exports.composeAsync=Q;exports.debounce=F;exports.debouncePromise=G;exports.decodeURIParams=H;exports.encodeURIParams=$;exports.getOnLoadParams=W;exports.getPascalCase=B;exports.getQueryParams=R;exports.getQueryParamsFromHash=J;exports.getQueryParamsFromSearch=L;exports.getRandom=q;exports.getRandomStr=z;exports.pipe=j;exports.pipeAsync=O;exports.randomColor=N;exports.throttle=_;exports.toQueryString=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../_rollupPluginBabelHelpers-3cc6d021.js");function j(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("compose 参数必须是函数");return t.length===0?function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.length===1?n[0]:n}:t.reduce(function(r,n){return function(){for(var a=this,u=arguments.length,c=new Array(u),i=0;i<u;i++)c[i]=arguments[i];return n.call.apply(n,[this,function(){for(var s=arguments.length,m=new Array(s),l=0;l<s;l++)m[l]=arguments[l];return r.apply(a,m.concat(c))}].concat(c))}},function(r){return r})}function O(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("composeAsync 参数必须是函数");return t.length===0?f._asyncToGenerator(f._regenerator().m(function r(){var n,a,u,c=arguments;return f._regenerator().w(function(i){for(;;)switch(i.n){case 0:for(n=c.length,a=new Array(n),u=0;u<n;u++)a[u]=c[u];return i.a(2,a.length===1?a[0]:a)}},r)})):t.reduce(function(r,n){return f._asyncToGenerator(f._regenerator().m(function a(){var u=this,c,i,s,m=arguments;return f._regenerator().w(function(l){for(;;)switch(l.n){case 0:for(c=m.length,i=new Array(c),s=0;s<c;s++)i[s]=m[s];return l.a(2,n.call.apply(n,[this,f._asyncToGenerator(f._regenerator().m(function v(){var y,P,p,h=arguments;return f._regenerator().w(function(g){for(;;)switch(g.n){case 0:for(y=h.length,P=new Array(y),p=0;p<y;p++)P[p]=h[p];return g.a(2,r.apply(u,P.concat(i)))}},v)}))].concat(i)))}},a,this)}))},function(){var r=f._asyncToGenerator(f._regenerator().m(function n(a){return f._regenerator().w(function(u){for(;;)switch(u.n){case 0:return u.a(2,a)}},n)}));return function(n){return r.apply(this,arguments)}}())}function F(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("pipe 参数必须是函数");return t.length===0?function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.length===1?n[0]:n}:t.reverse().reduce(function(r,n){return function(){for(var a=this,u=arguments.length,c=new Array(u),i=0;i<u;i++)c[i]=arguments[i];return n.call.apply(n,[this,function(){for(var s=arguments.length,m=new Array(s),l=0;l<s;l++)m[l]=arguments[l];return r.apply(a,m.concat(c))}].concat(c))}},function(r){return r})}function G(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];if(t.some(function(r){return typeof r!="function"}))throw new TypeError("pipeAsync 参数必须是函数");return t.length===0?f._asyncToGenerator(f._regenerator().m(function r(){var n,a,u,c=arguments;return f._regenerator().w(function(i){for(;;)switch(i.n){case 0:for(n=c.length,a=new Array(n),u=0;u<n;u++)a[u]=c[u];return i.a(2,a.length===1?a[0]:a)}},r)})):t.reverse().reduce(function(r,n){return f._asyncToGenerator(f._regenerator().m(function a(){var u=this,c,i,s,m=arguments;return f._regenerator().w(function(l){for(;;)switch(l.n){case 0:for(c=m.length,i=new Array(c),s=0;s<c;s++)i[s]=m[s];return l.a(2,n.call.apply(n,[this,f._asyncToGenerator(f._regenerator().m(function v(){var y,P,p,h=arguments;return f._regenerator().w(function(g){for(;;)switch(g.n){case 0:for(y=h.length,P=new Array(y),p=0;p<y;p++)P[p]=h[p];return g.a(2,r.apply(u,P.concat(i)))}},v)}))].concat(i)))}},a,this)}))},function(){var r=f._asyncToGenerator(f._regenerator().m(function n(a){return f._regenerator().w(function(u){for(;;)switch(u.n){case 0:return u.a(2,a)}},n)}));return function(n){return r.apply(this,arguments)}}())}function I(e,t){var o=null;r.stop=function(){return o&&clearTimeout(o)};function r(){for(var n=this,a=arguments.length,u=new Array(a),c=0;c<a;c++)u[c]=arguments[c];return r.stop(),o=setTimeout(function(){e.apply(n,u)},t),o}return r}function U(e,t){var o=null,r=[];n.stop=function(){if(o){var a;(a=r.shift())===null||a===void 0||a("cancel"),clearTimeout(o)}};function n(){for(var a=this,u=arguments.length,c=new Array(u),i=0;i<u;i++)c[i]=arguments[i];return new Promise(function(s,m){n.stop(),r.push(m),o=setTimeout(function(){s(e.apply(a,c))},t)})}return n}function H(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:500,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r,n,a=o?function(){if(!n){n=!0;for(var u=arguments.length,c=new Array(u),i=0;i<u;i++)c[i]=arguments[i];return typeof e=="function"&&e.apply(this,c),r=setTimeout(function(){n=!1},t),r}}:function(){for(var u=this,c=arguments.length,i=new Array(c),s=0;s<c;s++)i[s]=arguments[s];if(!n)return n=!0,r=setTimeout(function(){n=!1,typeof e=="function"&&e.apply(u,i)},t),r};return a.stop=function(){return r&&clearTimeout(r)},a}function L(e){return encodeURIComponent(JSON.stringify(e||{}))}function J(e){return JSON.parse(decodeURIComponent(e||"{}"))}function R(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t.decode,r=o===void 0?!0:o,n=t.silent,a=n===void 0?!1:n,u=t.decodePlus,c=u===void 0?!0:u,i=t.strict,s=i===void 0?!1:i,m={};if(typeof e!="string")return m;function l(Q,_){if(!r)return Q;var T=Q;c&&(T=T.replace(/\+/g," "));try{return decodeURIComponent(T)}catch($){return a||console.warn("Failed to decode ".concat(_?"key":"value",": ").concat(T),$),s?null:(_&&(T=T.replace(/%[0-9a-f]{2}/gi,"")),T)}}var v=e.split("#")[0],y=v.indexOf("?"),P=y>=0?v.slice(y+1):v;if(!P)return m;for(var p=P.split("&"),h=0;h<p.length;h++){var g=p[h];if(g){var d=g.indexOf("="),w=void 0,A=void 0;d===-1?(w=g,A=""):(w=g.slice(0,d),A=g.slice(d+1));var S=l(w,!0);if(!(S===null||!S)){var b=l(A,!1);if(b!==null){var C=S,M=!1;/\[\]$/.test(S)?(C=S.slice(0,-2),M=!0):/^(.+)\[\d+\]$/.test(S)&&(C=S.replace(/\[\d+\]$/,""),M=!0);var E=m[C];E===void 0?m[C]=M?[b]:b:Array.isArray(E)?E.push(b):m[C]=[E,b]}}}}return m}function q(e){return typeof window=="undefined"?{}:R(window.location.search,e)}function B(e){if(typeof window=="undefined")return{};var t=window.location.hash,o=t.indexOf("?");if(o===-1)return{};var r=t.substring(o);return R(r,e)}function D(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"-";return[Date.now().toString(),Math.random().toString(16).slice(2,10),Math.random().toString(16).slice(7),e.toString()].join(t)}function N(e){return e.replace(/([^-])([^-]*)/g,function(t,o,r){return o.toLocaleUpperCase()+r.toLocaleLowerCase()}).replace(/-/g,"")}function z(e,t){e=e.split("."),t=t.split(".");for(var o=Math.max(e.length,t.length);e.length<o;)e.push("0");for(;t.length<o;)t.push("0");for(var r=0;r<o;r++){var n=parseInt(e[r]),a=parseInt(t[r]);if(n>a)return 1;if(n<a)return-1}return 0}function V(){return"#"+Math.floor(Math.random()*16777215).toString(16).padEnd(6,"0")}function W(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:8,t=arguments.length>1?arguments[1]:void 0;e=e||32,t||(t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678");for(var o=t.length,r="",n=0;n<e;n++)r+=t.charAt(Math.floor(Math.random()*o));return r}function X(e){var t,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e||f._typeof(e)!=="object")return"";var r=o.addQuestionMark,n=r===void 0?!1:r,a=o.encode,u=a===void 0?!0:a,c=o.arrayFormat,i=c===void 0?"comma":c,s=o.keepEmptyArray,m=s===void 0?!1:s,l=[];function v(h){return u?encodeURIComponent(h):h}var y={indices:function(g,d){d.forEach(function(w,A){l.push("".concat(g,"[").concat(A,"]=").concat(v(w)))})},brackets:function(g,d){d.forEach(function(w){l.push("".concat(g,"[]=").concat(v(w)))})},repeat:function(g,d){d.forEach(function(w){l.push("".concat(g,"=").concat(v(w)))})},comma:function(g,d){var w=d.map(function(A){return v(A)}).join(",");l.push("".concat(g,"=").concat(w))}},P=(t=y[i])!==null&&t!==void 0?t:y.comma;Object.keys(e).forEach(function(h){var g=e[h];if(g!=null){var d=v(h);if(Array.isArray(g)){var w=g.filter(function(S){return S!=null});if(w.length===0){m&&l.push("".concat(d,"="));return}P(d,w);return}var A=g;f._typeof(A)==="object"&&A!==null&&(A=JSON.stringify(A)),l.push("".concat(d,"=").concat(v(A)))}});var p=l.join("&");return n&&p?"?".concat(p):p}function Y(e){var t=e.scene;return t&&(e=f._objectSpread2(f._objectSpread2({fromCode:!0},e),R(t))),e}exports.compareVersion=z;exports.compose=j;exports.composeAsync=O;exports.debounce=I;exports.debouncePromise=U;exports.decodeURIParams=J;exports.encodeURIParams=L;exports.getOnLoadParams=Y;exports.getPascalCase=N;exports.getQueryParams=R;exports.getQueryParamsFromHash=B;exports.getQueryParamsFromSearch=q;exports.getRandom=D;exports.getRandomStr=W;exports.pipe=F;exports.pipeAsync=G;exports.randomColor=V;exports.throttle=H;exports.toQueryString=X;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utils-uniapp",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
4
4
  "description": "aubyn's utils for uniapp",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",