pubo-utils 1.0.148 → 1.0.149

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
- !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["pubo-utils"]=n():t["pubo-utils"]=n()}(this,(()=>(()=>{"use strict";var t={d:(n,e)=>{for(var r in e)t.o(e,r)&&!t.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:e[r]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{Base64Utils:()=>e,ContinuousTrigger:()=>k,Emitter:()=>y,HistoryStack:()=>N,Level:()=>C,RegExpList:()=>Y,SensorDataFilter:()=>tt,StringSplit:()=>nt,SyncQueue:()=>O,WatchDog:()=>U,callbackToPromise:()=>L,debounce:()=>r,degrees:()=>X,filterKeyPoints:()=>H,getAngle:()=>q,getBestPointIndex:()=>W,getCenter:()=>K,getDistance:()=>F,getPositionTheta:()=>V,getRotate:()=>Q,getVectorTheta:()=>J,hex2rgb:()=>i,loop:()=>P,lower2camel:()=>et,orderByDistance:()=>G,radians:()=>$,random:()=>o,randomRangeNum:()=>u,sleep:()=>b,superFactory:()=>m,throttle:()=>M,waitFor:()=>S});var e={};t.r(e),t.d(e,{EncoderMap:()=>E,toUnit8Array:()=>I});var r=function(t,n,e){if(void 0===e&&(e=!1),e){var r,i=!0;return function(){i&&(t.apply(void 0,arguments),i=!1),r&&clearTimeout(r),r=setTimeout((function(){return i=!0}),n)}}var o;return function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];o&&clearTimeout(o),o=setTimeout((function(){return t.apply(void 0,r)}),n)}},i=function(t){var n=("string"==typeof t?function(t){return parseInt(t.replace("#",""),16)}(t):t).toString(2).padStart(24,"0");return[parseInt(n.slice(0,8),2),parseInt(n.slice(8,16),2),parseInt(n.slice(16,24),2)]},o=function(t){void 0===t&&(t=8);var n=function(t){return Math.random().toString(32).slice(2,2+t)};if(t<=8)return n(t);for(var e="",r=0;r<=t;r+=8)e+=n(t-r>8?8:t-r);return e},u=function(t){var n=Math.abs(t[1]-t[0]);return Math.random()*n+Math.min.apply(Math,t)};function a(){}function s(t){var n=t();if(n&&n.then)return n.then(a)}var c="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function f(t,n,e){if(!t.s){if(e instanceof h){if(!e.s)return void(e.o=f.bind(null,t,n));1&n&&(n=e.s),e=e.v}if(e&&e.then)return void e.then(f.bind(null,t,n),f.bind(null,t,2));t.s=n,t.v=e;var r=t.o;r&&r(t)}}var h=function(){function t(){}return t.prototype.then=function(n,e){var r=new t,i=this.s;if(i){var o=1&i?n:e;if(o){try{f(r,1,o(this.v))}catch(t){f(r,2,t)}return r}return this}return this.o=function(t){try{var i=t.v;1&t.s?f(r,1,n?n(i):i):e?f(r,1,e(i)):f(r,2,i)}catch(t){f(r,2,t)}},r},t}();function l(t){return t instanceof h&&1&t.s}function v(){return v=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},v.apply(this,arguments)}function p(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var y=function(){function t(){this.state={},this.ids={}}var n=t.prototype;return n.on=function(t,n){if(this.state[t]||(this.state[t]=[]),"function"!=typeof n)throw new Error("第二个参数必须为function!");var e=this.state[t].push(n)-1,r=o(40);return this.ids[r]={event:t,index:e},r},n.cancel=function(t){var n=this;if(t){var e=this.ids[t]||{},r=e.event,i=e.index;r&&Array.isArray(this.state[r])&&(this.state[r].splice(i,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){n.ids[t].event===r&&n.ids[t].index>i&&(n.ids[t].index=n.ids[t].index-1)})))}else this.clear()},n.clear=function(){this.state.length=0},n.emit=function(t,n){if(Array.isArray(this.state[t]))for(var e,r=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return p(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?p(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.state[t]);!(e=r()).done;){var i=e.value;"function"==typeof i&&i(n)}},n.emitSync=function(t,n){try{var e=this;return(r=s((function(){if(Array.isArray(e.state[t]))return function(t){if(t&&t.then)return t.then(a)}(function(t,n,e){if("function"==typeof t[c]){var r,i,o,u=t[c]();if(function t(a){try{for(;!((r=u.next()).done||e&&e());)if((a=n(r.value))&&a.then){if(!l(a))return void a.then(t,o||(o=f.bind(null,i=new h,2)));a=a.v}i?f(i,1,a):i=a}catch(t){f(i||(i=new h),2,t)}}(),u.return){var a=function(t){try{r.done||u.return()}catch(t){}return t};if(i&&i.then)return i.then(a,(function(t){throw a(t)}));a()}return i}if(!("length"in t))throw new TypeError("Object is not iterable");for(var s=[],v=0;v<t.length;v++)s.push(t[v]);return function(t,n,e){var r,i,o=-1;return function u(a){try{for(;++o<t.length&&(!e||!e());)if((a=n(o))&&a.then){if(!l(a))return void a.then(u,i||(i=f.bind(null,r=new h,2)));a=a.v}r?f(r,1,a):r=a}catch(t){f(r||(r=new h),2,t)}}(),r}(s,(function(t){return n(s[t])}),e)}(e.state[t],(function(t){return s((function(){if("function"==typeof t)return function(t,n){return t&&t.then?t.then(a):Promise.resolve()}(t(n))}))})))})))&&r.then||(r=Promise.resolve(r)),r}catch(t){return Promise.reject(t)}var r},n.clone=function(){return{state:v({},this.state),ids:v({},this.ids)}},n.restore=function(t){this.state=t.state,this.ids=t.ids},t}(),m=function(t){return function(n){for(var e={},r=0,i=Object.keys(n);r<i.length;r++){var o=i[r];e[o]=t(n[o],o)}return e}};function d(){}var g,b=(g=function(t){return(n=new Promise((function(n){var e=setTimeout((function(){n(),clearTimeout(e),e=null}),t)})))&&n.then?n.then(d):Promise.resolve();var n},function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(g.apply(this,t))}catch(t){return Promise.reject(t)}});function w(){}function j(t,n,e){if(e)return n?n(t()):t();try{var r=Promise.resolve(t());return n?r.then(n):r}catch(t){return Promise.reject(t)}}var P=function(t,n){var e=!0,r=function(){e=!1},i=function(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];try{return Promise.resolve(t.apply(this,n))}catch(t){return Promise.reject(t)}}}((function(){return u=function(){return u=function(){e?i():(i=null,t=null,r=null,e=null,n=null)},(o=b(n))&&o.then||(o=Promise.resolve(o)),u?o.then(u):o;var o,u},(o=function(n,e){try{var r=j(t,w,i)}catch(t){return e(t)}var i;return r&&r.then?r.then(void 0,e):r}(0,(function(t){console.log(t)})))&&o.then?o.then(u):u();var o,u}));return i(),r},S=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,i=e.timeout;return new Promise((function(n,e){var o,u=P((function(){return j(t,(function(e){e&&("function"==typeof u&&u(),o&&(clearTimeout(o),o=null),n(e),u=null,t=null,n=null)}))}),r||100);i&&(o=setTimeout((function(){"function"==typeof u&&u(),o&&(clearTimeout(o),o=null),e("timeout"),e=null,u=null,t=null}),i))}))};function x(t,n,e){return e?n?n(t):t:(t&&t.then||(t=Promise.resolve(t)),n?t.then(n):t)}function T(){}function A(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var O=function(){function t(){this.cache=[],this.running=!1,this.len=0}var n,e,r=t.prototype;return r._run=function(t){var n,e,r=t.fn,i=t.promise;try{return x((n=function(t,n){try{var e=function(t,n,e){try{var r=Promise.resolve(t());return n?r.then(n):r}catch(t){return Promise.reject(t)}}(r,(function(t){i.resolve(t)}))}catch(t){return n(t)}return e&&e.then?e.then(void 0,n):e}(0,(function(t){i.reject(t)})),e=function(){r=null,i=null},n&&n.then?n.then(e):e()))}catch(t){return Promise.reject(t)}},r.run=function(){try{var t=this;if(t.cache.length<1)return t.running=!1,x();t.running=!0;var n=t.cache.shift();return t.len-=1,x((e=function(){t.run()},(r=function(){if("function"==typeof n.fn)return(e=t._run(n))&&e.then?e.then(T):Promise.resolve();var e}())&&r.then?r.then(e):e()))}catch(t){return Promise.reject(t)}var e,r},r.push=function(t){var n=this;return this.len+=1,new Promise((function(e,r){n.cache.push({fn:t,promise:{resolve:e,reject:r}}),n.running||n.run()}))},n=t,(e=[{key:"length",get:function(){return this.len}}])&&A(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}();function M(t,n){var e,r=!0;return function(){e||(e=setTimeout((function(){r=!0,e=null}),n)),r&&(r=!1,t.apply(void 0,arguments))}}function _(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var k=function(){function t(t){this.timeout=void 0,this._count=0,this.props=void 0,this.props=t}var n,e,r=t.prototype;return r.increment=function(){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return t.clear()}),this.props.resetTime),this._count=this._count+1,this._count>this.props.count&&this.props.cb()},r.clear=function(){this._count=0},n=t,(e=[{key:"count",get:function(){return this._count}}])&&_(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),E=function(){for(var t={},n=0;n<64;n++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n)]=n;return t}();function I(t){for(var n=new Uint8Array(6*t.length/8),e=0,r=0,i=0,o=0;o<t.length&&i<n.length;o+=1)if(r=(r<<6)+E[t.charAt(o)],(e+=6)>=8){var u=r>>>(e-=8);n[i++]=255&u,r-=u<<=e}return n}function R(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var N=function(){function t(t){void 0===t&&(t=10),this.stack=[],this.len=10,this.point=0,this.len=t}var n,e,r=t.prototype;return r.clear=function(){this.stack.length=0,this.point=0},r.backup=function(t){this.point>0&&this.stack.length>0&&(this.stack.splice(0,this.point),this.point=0),this.stack.unshift(t),this.stack.length>this.len&&this.stack.pop()},r.undo=function(){return this.point<this.stack.length-1&&(this.point+=1),this.current},r.redo=function(){return this.point>0&&(this.point-=1),this.current},n=t,(e=[{key:"current",get:function(){if(this.point<this.stack.length&&this.point>-1)return this.stack[this.point]}}])&&R(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),U=function(){function t(t){var n=this,e=t.limit,r=void 0===e?10:e,i=t.onTimeout;this.onTimeout=void 0,this.timeout=null,this._time=void 0,this._time=1e3*r,this.onTimeout=function(){i(),n.timeout&&(clearTimeout(n.timeout),n.timeout=null)}}var n=t.prototype;return n.feed=function(){this.init()},n.init=function(){var t=this;clearTimeout(this.timeout),this.timeout=null,this.timeout=setTimeout((function(){return t.onTimeout()}),this._time)},n.stop=function(){this.timeout&&clearTimeout(this.timeout),delete this.timeout},t}(),C=function(){function t(t){this.config=void 0,this.step=void 0,this.config=t,this.step=(this.config.max-this.config.min)/(this.config.count-2)}return t.prototype.get=function(t){if(t<=this.config.min)return 1;if(t>=this.config.max)return this.config.count;for(var n=2,e=this.config.min+this.step;e<this.config.max+this.step;e+=this.step,n+=1)if(t<e)return n;return this.config.count},t}(),L=function(t){return function(){for(var n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return new Promise((function(n,r){t.apply(void 0,e.concat([function(t){t&&r(t);for(var e=arguments.length,i=new Array(e>1?e-1:0),o=1;o<e;o++)i[o-1]=arguments[o];i.length<2?n(i[0]):n([].concat(i))}])),t=null}))}};function z(){return z=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},z.apply(this,arguments)}function D(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return B(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?B(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function B(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var F=function(t,n){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))},X=function(t){return 180*t/Math.PI},$=function(t){return t*Math.PI/180},q=function(t){var n=t.w,e=t.h;return X(Math.atan2(e,n))};function H(t,n){return void 0===n&&(n=.5),t.length<3||n<=0?t:t.filter((function(r,i){return!(i>0&&F(e,r)<n||(e=t[i],0))}));var e}function K(t){for(var n,e=[0,0],r=D(t);!(n=r()).done;){var i=n.value;Array.isArray(i)?(e[0]+=i[0],e[1]+=i[1]):(e[0]+=i.x,e[1]+=i.y)}return{x:e[0]/t.length,y:e[1]/t.length}}function Q(t,n){return[Math.cos(n)*t[0]-Math.sin(n)*t[1],Math.sin(n)*t[0]+Math.cos(n)*t[1]]}var V=function(t,n){var e={x:n.x-t.x,y:n.y-t.y};return Math.atan2(e.y,e.x)},W=function(t,n){if(t.length<2)return 0;for(var e,r=[],i=1/0,o=0,u=D(t);!(e=u()).done;){var a=e.value,s=F(a,n),c=V(n,a)-n.theta;i>s&&(i=s),r.push(z({},a,{index:o,distance:s,theta:c})),o+=1}var f=r.filter((function(t){return t.distance-i<.1})).sort((function(t,n){return t.theta-n.theta}));return f[0].index},G=function(t,n){void 0===n&&(n={x:0,y:0,theta:0});for(var e=n,r=[],i=[].concat(t);i.length>0;){var o=W(i,e);r.push(i[o]),e=i[o],i.splice(o,1)}return r},J=function(t,n){return Math.atan2(n.y,n.x)-Math.atan2(t.y,t.x)},Y=function(){function t(t){this.list=void 0,this._RegExpList=null,this.list=t}var n=t.prototype;return n.getRegEXP=function(t){var n=t.replace("/","\\/").replace("*",".*");return new RegExp(n)},n.include=function(t){return this._RegExpList||(this._RegExpList=this.list.map(this.getRegEXP)),this._RegExpList.some((function(n){return n.test(t)}))},t}();function Z(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var tt=function(){function t(t){var n=void 0===t?{}:t,e=n.size,r=void 0===e?5:e,i=n.step,o=void 0===i?5:i,u=n.min,a=void 0===u?-1/0:u,s=n.max,c=void 0===s?1/0:s;this.tmp=[],this.size=void 0,this.step=void 0,this.min=void 0,this.max=void 0,this.count=0,this.value=NaN,this.old=void 0,this.size=r,this.step=o,this.min=a,this.max=c}var n=t.prototype;return n.filter=function(t){return t<this.min||t>this.max||(this.tmp.push(t),this.old=this.calc(t)),this.old},n.calc=function(t){if(this.tmp.length<1)return t;this.tmp.length>this.size&&this.tmp.shift();var n=this.getMostNumberOfTmp(),e=n.res,r=n.dic;return e!==t&&Math.abs(e-t)>this.step?(this.value!==t?this.count=1:this.count+=1,this.value=t,this.count>r[e]?(this.tmp.length=0,this.tmp.push(t),t):e):(this.count=0,this.value=NaN,t)},n.getMostNumberOfTmp=function(){for(var t,n,e={},r=0,i=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return Z(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Z(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.tmp);!(n=i()).done;){var o=n.value;e[o]?e[o]+=1:e[o]=1,e[o]>r&&(r=e[o],t=o)}return{res:t,dic:e}},t}(),nt=function(){function t(t){this._splitSymbol=void 0,this._cache="",this._splitSymbol=t}return t.prototype.split=function(t){var n=(this._cache+t).split(this._splitSymbol);return this._cache=n.splice(n.length-1,1)[0],n},t}(),et=function(t){return t.split("_").map((function(t,n){return n>0?t.slice(0,1).toUpperCase()+t.slice(1):t})).join("")};return n})()));
1
+ !function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["pubo-utils"]=n():t["pubo-utils"]=n()}(this,(()=>(()=>{"use strict";var t={d:(n,e)=>{for(var r in e)t.o(e,r)&&!t.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:e[r]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},n={};t.r(n),t.d(n,{Base64Utils:()=>e,ContinuousTrigger:()=>k,Emitter:()=>m,HistoryStack:()=>N,Level:()=>C,RegExpList:()=>Y,SensorDataFilter:()=>tt,StringSplit:()=>nt,SyncQueue:()=>O,WatchDog:()=>U,callbackToPromise:()=>L,debounce:()=>r,degrees:()=>X,filterKeyPoints:()=>H,getAngle:()=>q,getBestPointIndex:()=>W,getCenter:()=>K,getDistance:()=>F,getPositionTheta:()=>V,getRotate:()=>Q,getVectorTheta:()=>J,hex2rgb:()=>i,loop:()=>P,lower2camel:()=>et,orderByDistance:()=>G,radians:()=>$,random:()=>o,randomRangeNum:()=>u,sleep:()=>b,superFactory:()=>y,throttle:()=>M,waitFor:()=>S});var e={};t.r(e),t.d(e,{EncoderMap:()=>E,toUnit8Array:()=>I});var r=function(t,n,e){if(void 0===e&&(e=!1),e){var r,i=!0;return function(){i&&(t.apply(void 0,arguments),i=!1),r&&clearTimeout(r),r=setTimeout((function(){clearTimeout(r),i=!0,r=null}),n)}}var o;return function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];o&&(clearTimeout(o),o=null),o=setTimeout((function(){t.apply(void 0,r),clearTimeout(o),r=null,o=null}),n)}},i=function(t){var n=("string"==typeof t?function(t){return parseInt(t.replace("#",""),16)}(t):t).toString(2).padStart(24,"0");return[parseInt(n.slice(0,8),2),parseInt(n.slice(8,16),2),parseInt(n.slice(16,24),2)]},o=function(t){void 0===t&&(t=8);var n=function(t){return Math.random().toString(32).slice(2,2+t)};if(t<=8)return n(t);for(var e="",r=0;r<=t;r+=8)e+=n(t-r>8?8:t-r);return e},u=function(t){var n=Math.abs(t[1]-t[0]);return Math.random()*n+Math.min.apply(Math,t)};function a(){}function s(t){var n=t();if(n&&n.then)return n.then(a)}var c="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function f(t,n,e){if(!t.s){if(e instanceof l){if(!e.s)return void(e.o=f.bind(null,t,n));1&n&&(n=e.s),e=e.v}if(e&&e.then)return void e.then(f.bind(null,t,n),f.bind(null,t,2));t.s=n,t.v=e;var r=t.o;r&&r(t)}}var l=function(){function t(){}return t.prototype.then=function(n,e){var r=new t,i=this.s;if(i){var o=1&i?n:e;if(o){try{f(r,1,o(this.v))}catch(t){f(r,2,t)}return r}return this}return this.o=function(t){try{var i=t.v;1&t.s?f(r,1,n?n(i):i):e?f(r,1,e(i)):f(r,2,i)}catch(t){f(r,2,t)}},r},t}();function h(t){return t instanceof l&&1&t.s}function v(){return v=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},v.apply(this,arguments)}function p(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var m=function(){function t(){this.state={},this.ids={}}var n=t.prototype;return n.on=function(t,n){if(this.state[t]||(this.state[t]=[]),"function"!=typeof n)throw new Error("第二个参数必须为function!");var e=this.state[t].push(n)-1,r=o(40);return this.ids[r]={event:t,index:e},r},n.cancel=function(t){var n=this;if(t){var e=this.ids[t]||{},r=e.event,i=e.index;r&&Array.isArray(this.state[r])&&(this.state[r].splice(i,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){n.ids[t].event===r&&n.ids[t].index>i&&(n.ids[t].index=n.ids[t].index-1)})))}else this.clear()},n.clear=function(){this.state.length=0},n.emit=function(t,n){if(Array.isArray(this.state[t]))for(var e,r=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return p(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?p(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.state[t]);!(e=r()).done;){var i=e.value;"function"==typeof i&&i(n)}},n.emitSync=function(t,n){try{var e=this;return(r=s((function(){if(Array.isArray(e.state[t]))return function(t){if(t&&t.then)return t.then(a)}(function(t,n,e){if("function"==typeof t[c]){var r,i,o,u=t[c]();if(function t(a){try{for(;!((r=u.next()).done||e&&e());)if((a=n(r.value))&&a.then){if(!h(a))return void a.then(t,o||(o=f.bind(null,i=new l,2)));a=a.v}i?f(i,1,a):i=a}catch(t){f(i||(i=new l),2,t)}}(),u.return){var a=function(t){try{r.done||u.return()}catch(t){}return t};if(i&&i.then)return i.then(a,(function(t){throw a(t)}));a()}return i}if(!("length"in t))throw new TypeError("Object is not iterable");for(var s=[],v=0;v<t.length;v++)s.push(t[v]);return function(t,n,e){var r,i,o=-1;return function u(a){try{for(;++o<t.length&&(!e||!e());)if((a=n(o))&&a.then){if(!h(a))return void a.then(u,i||(i=f.bind(null,r=new l,2)));a=a.v}r?f(r,1,a):r=a}catch(t){f(r||(r=new l),2,t)}}(),r}(s,(function(t){return n(s[t])}),e)}(e.state[t],(function(t){return s((function(){if("function"==typeof t)return function(t,n){return t&&t.then?t.then(a):Promise.resolve()}(t(n))}))})))})))&&r.then||(r=Promise.resolve(r)),r}catch(t){return Promise.reject(t)}var r},n.clone=function(){return{state:v({},this.state),ids:v({},this.ids)}},n.restore=function(t){this.state=t.state,this.ids=t.ids},t}(),y=function(t){return function(n){for(var e={},r=0,i=Object.keys(n);r<i.length;r++){var o=i[r];e[o]=t(n[o],o)}return e}};function d(){}var g,b=(g=function(t){return(n=new Promise((function(n){var e=setTimeout((function(){n(),clearTimeout(e),e=null}),t)})))&&n.then?n.then(d):Promise.resolve();var n},function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(g.apply(this,t))}catch(t){return Promise.reject(t)}});function w(){}function j(t,n,e){if(e)return n?n(t()):t();try{var r=Promise.resolve(t());return n?r.then(n):r}catch(t){return Promise.reject(t)}}var P=function(t,n){var e=!0,r=function(){e=!1},i=function(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];try{return Promise.resolve(t.apply(this,n))}catch(t){return Promise.reject(t)}}}((function(){return u=function(){return u=function(){e?i():(i=null,t=null,r=null,e=null,n=null)},(o=b(n))&&o.then||(o=Promise.resolve(o)),u?o.then(u):o;var o,u},(o=function(n,e){try{var r=j(t,w,i)}catch(t){return e(t)}var i;return r&&r.then?r.then(void 0,e):r}(0,(function(t){console.log(t)})))&&o.then?o.then(u):u();var o,u}));return i(),r},S=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,i=e.timeout;return new Promise((function(n,e){var o,u=P((function(){return j(t,(function(e){e&&("function"==typeof u&&u(),o&&(clearTimeout(o),o=null),n(e),u=null,t=null,n=null)}))}),r||100);i&&(o=setTimeout((function(){"function"==typeof u&&u(),o&&(clearTimeout(o),o=null),e("timeout"),e=null,u=null,t=null}),i))}))};function x(t,n,e){return e?n?n(t):t:(t&&t.then||(t=Promise.resolve(t)),n?t.then(n):t)}function T(){}function A(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var O=function(){function t(){this.cache=[],this.running=!1,this.len=0}var n,e,r=t.prototype;return r._run=function(t){var n,e,r=t.fn,i=t.promise;try{return x((n=function(t,n){try{var e=function(t,n,e){try{var r=Promise.resolve(t());return n?r.then(n):r}catch(t){return Promise.reject(t)}}(r,(function(t){i.resolve(t)}))}catch(t){return n(t)}return e&&e.then?e.then(void 0,n):e}(0,(function(t){i.reject(t)})),e=function(){r=null,i=null},n&&n.then?n.then(e):e()))}catch(t){return Promise.reject(t)}},r.run=function(){try{var t=this;if(t.cache.length<1)return t.running=!1,x();t.running=!0;var n=t.cache.shift();return t.len-=1,x((e=function(){t.run()},(r=function(){if("function"==typeof n.fn)return(e=t._run(n))&&e.then?e.then(T):Promise.resolve();var e}())&&r.then?r.then(e):e()))}catch(t){return Promise.reject(t)}var e,r},r.push=function(t){var n=this;return this.len+=1,new Promise((function(e,r){n.cache.push({fn:t,promise:{resolve:e,reject:r}}),n.running||n.run()}))},n=t,(e=[{key:"length",get:function(){return this.len}}])&&A(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}();function M(t,n){var e,r=!0;return function(){for(var i=arguments.length,o=new Array(i),u=0;u<i;u++)o[u]=arguments[u];e||(e=setTimeout((function(){clearTimeout(e),r=!0,e=null}),n)),r&&(r=!1,t.apply(void 0,o)),o=null}}function _(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var k=function(){function t(t){this.timeout=void 0,this._count=0,this.props=void 0,this.props=t}var n,e,r=t.prototype;return r.increment=function(){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return t.clear()}),this.props.resetTime),this._count=this._count+1,this._count>this.props.count&&this.props.cb()},r.clear=function(){clearTimeout(this.timeout),this._count=0,this.timeout=0},n=t,(e=[{key:"count",get:function(){return this._count}}])&&_(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),E=function(){for(var t={},n=0;n<64;n++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n)]=n;return t}();function I(t){for(var n=new Uint8Array(6*t.length/8),e=0,r=0,i=0,o=0;o<t.length&&i<n.length;o+=1)if(r=(r<<6)+E[t.charAt(o)],(e+=6)>=8){var u=r>>>(e-=8);n[i++]=255&u,r-=u<<=e}return n}function R(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,"symbol"==typeof(i=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?i:String(i)),r)}var i}var N=function(){function t(t){void 0===t&&(t=10),this.stack=[],this.len=10,this.point=0,this.len=t}var n,e,r=t.prototype;return r.clear=function(){this.stack.length=0,this.point=0},r.backup=function(t){this.point>0&&this.stack.length>0&&(this.stack.splice(0,this.point),this.point=0),this.stack.unshift(t),this.stack.length>this.len&&this.stack.pop()},r.undo=function(){return this.point<this.stack.length-1&&(this.point+=1),this.current},r.redo=function(){return this.point>0&&(this.point-=1),this.current},n=t,(e=[{key:"current",get:function(){if(this.point<this.stack.length&&this.point>-1)return this.stack[this.point]}}])&&R(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),U=function(){function t(t){var n=this,e=t.limit,r=void 0===e?10:e,i=t.onTimeout;this.onTimeout=void 0,this.timeout=null,this._time=void 0,this._time=1e3*r,this.onTimeout=function(){n.timeout&&(clearTimeout(n.timeout),n.timeout=null),i()}}var n=t.prototype;return n.feed=function(){this.init()},n.init=function(){clearTimeout(this.timeout),this.timeout=null,delete this.timeout,this.timeout=setTimeout(this.onTimeout,this._time)},n.stop=function(){this.timeout&&clearTimeout(this.timeout),delete this.timeout},t}(),C=function(){function t(t){this.config=void 0,this.step=void 0,this.config=t,this.step=(this.config.max-this.config.min)/(this.config.count-2)}return t.prototype.get=function(t){if(t<=this.config.min)return 1;if(t>=this.config.max)return this.config.count;for(var n=2,e=this.config.min+this.step;e<this.config.max+this.step;e+=this.step,n+=1)if(t<e)return n;return this.config.count},t}(),L=function(t){return function(){for(var n=arguments.length,e=new Array(n),r=0;r<n;r++)e[r]=arguments[r];return new Promise((function(n,r){t.apply(void 0,e.concat([function(t){t&&r(t);for(var e=arguments.length,i=new Array(e>1?e-1:0),o=1;o<e;o++)i[o-1]=arguments[o];i.length<2?n(i[0]):n([].concat(i))}])),t=null}))}};function z(){return z=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},z.apply(this,arguments)}function D(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return B(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?B(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function B(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var F=function(t,n){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))},X=function(t){return 180*t/Math.PI},$=function(t){return t*Math.PI/180},q=function(t){var n=t.w,e=t.h;return X(Math.atan2(e,n))};function H(t,n){return void 0===n&&(n=.5),t.length<3||n<=0?t:t.filter((function(r,i){return!(i>0&&F(e,r)<n||(e=t[i],0))}));var e}function K(t){for(var n,e=[0,0],r=D(t);!(n=r()).done;){var i=n.value;Array.isArray(i)?(e[0]+=i[0],e[1]+=i[1]):(e[0]+=i.x,e[1]+=i.y)}return{x:e[0]/t.length,y:e[1]/t.length}}function Q(t,n){return[Math.cos(n)*t[0]-Math.sin(n)*t[1],Math.sin(n)*t[0]+Math.cos(n)*t[1]]}var V=function(t,n){var e={x:n.x-t.x,y:n.y-t.y};return Math.atan2(e.y,e.x)},W=function(t,n){if(t.length<2)return 0;for(var e,r=[],i=1/0,o=0,u=D(t);!(e=u()).done;){var a=e.value,s=F(a,n),c=V(n,a)-n.theta;i>s&&(i=s),r.push(z({},a,{index:o,distance:s,theta:c})),o+=1}var f=r.filter((function(t){return t.distance-i<.1})).sort((function(t,n){return t.theta-n.theta}));return f[0].index},G=function(t,n){void 0===n&&(n={x:0,y:0,theta:0});for(var e=n,r=[],i=[].concat(t);i.length>0;){var o=W(i,e);r.push(i[o]),e=i[o],i.splice(o,1)}return r},J=function(t,n){return Math.atan2(n.y,n.x)-Math.atan2(t.y,t.x)},Y=function(){function t(t){this.list=void 0,this._RegExpList=null,this.list=t}var n=t.prototype;return n.getRegEXP=function(t){var n=t.replace("/","\\/").replace("*",".*");return new RegExp(n)},n.include=function(t){return this._RegExpList||(this._RegExpList=this.list.map(this.getRegEXP)),this._RegExpList.some((function(n){return n.test(t)}))},t}();function Z(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var tt=function(){function t(t){var n=void 0===t?{}:t,e=n.size,r=void 0===e?5:e,i=n.step,o=void 0===i?5:i,u=n.min,a=void 0===u?-1/0:u,s=n.max,c=void 0===s?1/0:s;this.tmp=[],this.size=void 0,this.step=void 0,this.min=void 0,this.max=void 0,this.count=0,this.value=NaN,this.old=void 0,this.size=r,this.step=o,this.min=a,this.max=c}var n=t.prototype;return n.filter=function(t){return t<this.min||t>this.max||(this.tmp.push(t),this.old=this.calc(t)),this.old},n.calc=function(t){if(this.tmp.length<1)return t;this.tmp.length>this.size&&this.tmp.shift();var n=this.getMostNumberOfTmp(),e=n.res,r=n.dic;return e!==t&&Math.abs(e-t)>this.step?(this.value!==t?this.count=1:this.count+=1,this.value=t,this.count>r[e]?(this.tmp.length=0,this.tmp.push(t),t):e):(this.count=0,this.value=NaN,t)},n.getMostNumberOfTmp=function(){for(var t,n,e={},r=0,i=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return Z(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Z(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.tmp);!(n=i()).done;){var o=n.value;e[o]?e[o]+=1:e[o]=1,e[o]>r&&(r=e[o],t=o)}return{res:t,dic:e}},t}(),nt=function(){function t(t){this._splitSymbol=void 0,this._cache="",this._splitSymbol=t}return t.prototype.split=function(t){var n=(this._cache+t).split(this._splitSymbol);return this._cache=n.splice(n.length-1,1)[0],n},t}(),et=function(t){return t.split("_").map((function(t,n){return n>0?t.slice(0,1).toUpperCase()+t.slice(1):t})).join("")};return n})()));
@@ -14,7 +14,9 @@ export var debounce = function debounce(cb, time, first) {
14
14
  clearTimeout(t);
15
15
  }
16
16
  t = setTimeout(function () {
17
- return shouldRun = true;
17
+ clearTimeout(t);
18
+ shouldRun = true;
19
+ t = null;
18
20
  }, time);
19
21
  };
20
22
  } else {
@@ -25,9 +27,13 @@ export var debounce = function debounce(cb, time, first) {
25
27
  }
26
28
  if (_t) {
27
29
  clearTimeout(_t);
30
+ _t = null;
28
31
  }
29
32
  _t = setTimeout(function () {
30
- return cb.apply(void 0, args);
33
+ cb.apply(void 0, args);
34
+ clearTimeout(_t);
35
+ args = null;
36
+ _t = null;
31
37
  }, time);
32
38
  };
33
39
  }
@@ -2,15 +2,20 @@ export function throttle(cb, time) {
2
2
  var t;
3
3
  var onOff = true;
4
4
  return function () {
5
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6
+ args[_key] = arguments[_key];
7
+ }
5
8
  if (!t) {
6
9
  t = setTimeout(function () {
10
+ clearTimeout(t);
7
11
  onOff = true;
8
12
  t = null;
9
13
  }, time);
10
14
  }
11
15
  if (onOff) {
12
16
  onOff = false;
13
- cb.apply(void 0, arguments);
17
+ cb.apply(void 0, args);
14
18
  }
19
+ args = null;
15
20
  };
16
21
  }
@@ -22,7 +22,9 @@ export var ContinuousTrigger = /*#__PURE__*/function () {
22
22
  }
23
23
  };
24
24
  _proto.clear = function clear() {
25
+ clearTimeout(this.timeout);
25
26
  this._count = 0;
27
+ this.timeout = 0;
26
28
  };
27
29
  _createClass(ContinuousTrigger, [{
28
30
  key: "count",
@@ -9,11 +9,11 @@ export var WatchDog = /*#__PURE__*/function () {
9
9
  this._time = void 0;
10
10
  this._time = limit * 1000;
11
11
  this.onTimeout = function () {
12
- onTimeout();
13
12
  if (_this.timeout) {
14
13
  clearTimeout(_this.timeout);
15
14
  _this.timeout = null;
16
15
  }
16
+ onTimeout();
17
17
  };
18
18
  }
19
19
  var _proto = WatchDog.prototype;
@@ -21,12 +21,10 @@ export var WatchDog = /*#__PURE__*/function () {
21
21
  this.init();
22
22
  };
23
23
  _proto.init = function init() {
24
- var _this2 = this;
25
24
  clearTimeout(this.timeout);
26
25
  this.timeout = null;
27
- this.timeout = setTimeout(function () {
28
- return _this2.onTimeout();
29
- }, this._time);
26
+ delete this.timeout;
27
+ this.timeout = setTimeout(this.onTimeout, this._time);
30
28
  };
31
29
  _proto.stop = function stop() {
32
30
  if (this.timeout) {
@@ -13,7 +13,11 @@ const debounce = (cb, time, first = false) => {
13
13
  if (t) {
14
14
  clearTimeout(t);
15
15
  }
16
- t = setTimeout(() => (shouldRun = true), time);
16
+ t = setTimeout(() => {
17
+ clearTimeout(t);
18
+ shouldRun = true;
19
+ t = null;
20
+ }, time);
17
21
  };
18
22
  }
19
23
  else {
@@ -21,8 +25,14 @@ const debounce = (cb, time, first = false) => {
21
25
  return (...args) => {
22
26
  if (t) {
23
27
  clearTimeout(t);
28
+ t = null;
24
29
  }
25
- t = setTimeout(() => cb(...args), time);
30
+ t = setTimeout(() => {
31
+ cb(...args);
32
+ clearTimeout(t);
33
+ args = null;
34
+ t = null;
35
+ }, time);
26
36
  };
27
37
  }
28
38
  };
@@ -7,6 +7,7 @@ function throttle(cb, time) {
7
7
  return (...args) => {
8
8
  if (!t) {
9
9
  t = setTimeout(() => {
10
+ clearTimeout(t);
10
11
  onOff = true;
11
12
  t = null;
12
13
  }, time);
@@ -15,6 +16,7 @@ function throttle(cb, time) {
15
16
  onOff = false;
16
17
  cb(...args);
17
18
  }
19
+ args = null;
18
20
  };
19
21
  }
20
22
  exports.throttle = throttle;
@@ -20,7 +20,9 @@ class ContinuousTrigger {
20
20
  }
21
21
  }
22
22
  clear() {
23
+ clearTimeout(this.timeout);
23
24
  this._count = 0;
25
+ this.timeout = 0;
24
26
  }
25
27
  }
26
28
  exports.ContinuousTrigger = ContinuousTrigger;
@@ -8,11 +8,11 @@ class WatchDog {
8
8
  constructor({ limit = 10, onTimeout }) {
9
9
  this._time = limit * 1000;
10
10
  this.onTimeout = () => {
11
- onTimeout();
12
11
  if (this.timeout) {
13
12
  clearTimeout(this.timeout);
14
13
  this.timeout = null;
15
14
  }
15
+ onTimeout();
16
16
  };
17
17
  }
18
18
  feed() {
@@ -21,7 +21,8 @@ class WatchDog {
21
21
  init() {
22
22
  clearTimeout(this.timeout);
23
23
  this.timeout = null;
24
- this.timeout = setTimeout(() => this.onTimeout(), this._time);
24
+ delete this.timeout;
25
+ this.timeout = setTimeout(this.onTimeout, this._time);
25
26
  }
26
27
  stop() {
27
28
  if (this.timeout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-utils",
3
- "version": "1.0.148",
3
+ "version": "1.0.149",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "engines": {
19
19
  "node": ">=8.0.0"
20
20
  },
21
- "gitHead": "f4a2958b545a93f432d92b5203b08e0b464c0f68",
21
+ "gitHead": "2fb3948cc5dc5030739ce34928e4ec8195b55c1b",
22
22
  "devDependencies": {
23
23
  "@babel/cli": "^7.10.1",
24
24
  "@babel/core": "^7.10.2",