pubo-utils 1.0.192 → 1.0.194

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,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PuboUtils=e():t.PuboUtils=e()}(this,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Base64Utils:()=>i,BufferSplit:()=>vt,CacheEmitter:()=>m,ColorUtils:()=>h,ContinuousTrigger:()=>_,Emitter:()=>f,HistoryStack:()=>S,Level:()=>k,LinearColor:()=>c,RegExpList:()=>W,RetryPlus:()=>M,SensorDataFilter:()=>$,StringSplit:()=>H,SyncQueue:()=>x,UTM:()=>s,WatchDog:()=>L,callbackToPromise:()=>P,cloneDeep:()=>K,debounce:()=>n,degrees:()=>R,filterKeyPoints:()=>z,filterTree:()=>G,fixNum:()=>X,flatTree:()=>Z,getAngle:()=>O,getBestPointIndex:()=>D,getCenter:()=>C,getDistance:()=>N,getPositionTheta:()=>I,getRotate:()=>U,getTreeItem:()=>Q,getVectorTheta:()=>F,hex2rgb:()=>o,loop:()=>d,lower2camel:()=>q,orderByDistance:()=>B,radians:()=>j,random:()=>u,randomRangeNum:()=>l,reflection:()=>J,retry:()=>b,runAsyncTasks:()=>T,searchTree:()=>V,sleep:()=>g,superFactory:()=>p,throttle:()=>A,timeout:()=>y,waitFor:()=>w});var i={};t.r(i),t.d(i,{EncoderMap:()=>v,toUnit8Array:()=>E});var s={};t.r(s),t.d(s,{fromLatLon:()=>xt,latLonToZoneNumber:()=>At,latitudeToZoneLetter:()=>Tt,toLatLon:()=>Mt});const n=(t,e,i=!1)=>{if(i){let i,s=!0;return(...n)=>{s&&(t(...n),s=!1),i&&clearTimeout(i),i=setTimeout((()=>{clearTimeout(i),s=!0,i=null}),e)}}{let i;return(...s)=>{i&&(clearTimeout(i),i=null),i=setTimeout((()=>{t(...s),clearTimeout(i),s=null,i=null}),e)}}},r=t=>parseInt(t.replace("#",""),16),o=t=>{let e;e="string"==typeof t?r(t):t;const i=e.toString(2).padStart(24,"0");return[parseInt(i.slice(0,8),2),parseInt(i.slice(8,16),2),parseInt(i.slice(16,24),2)]},a=t=>"#"+[0,1,2].map((e=>t[e].toString(16))).join("");class h{int;constructor(t){"number"==typeof t?this.int=t:"string"==typeof t?this.int=r(t):Array.isArray(t)&&(this.int=r(a(t)))}getRgbArray(){return o(this.int)}get rgb(){return`rba(${this.getRgbArray().join(", ")})`}get hex(){return a(this.getRgbArray())}toString(t="hex"){return"rgb"===t?this.rgb:this.hex}}class c{base=[255,0,0];intensity=1;min;max;constructor({base:t=[255,0,0],intensity:e=1}={}){this.base=t,this.intensity=e,this.intensity<1&&(this.intensity=1),this.min=this.base[1],this.max=this.base[0],Math.abs(this.min-this.max)<1&&(this.min=0,this.max=255)}getColor(t){if(t<0)return this.base;let e=this.base[0],i=this.base[1],s=this.base[2],n=t*this.intensity;return i=this.base[1]+n,i<this.max||(n=i-this.max,i=this.max,e=this.base[0]-n,e>this.min||(n=this.min-e,e=this.min,s=this.base[2]+n,s<this.max||(n=s-this.max,s=this.max,i-=n,i>this.min||(n=this.min-i,i=this.min,e+=n,e<this.max||(n=e-this.max,e=this.max,s-=n,s>this.min||(s=this.min)))))),[e,i,s]}}const u=(t=8)=>{const e=t=>Math.random().toString(32).slice(2,2+t);if(t<=8)return e(t);let i="";for(let s=0;s<=t;s+=8)i+=e(t-s>8?8:t-s);return i},l=t=>{const e=Math.abs(t[1]-t[0]);return Math.random()*e+Math.min(...t)};class f{state={};ids={};on(t,e){if(this.state[t]||(this.state[t]={}),"function"!=typeof e)throw new Error("第二个参数必须为function!");const i=`${u(40)}_${(new Date).valueOf()}`;return this.state[t][i]=e,this.ids[i]=t,i}cancel(t){if(!t)return void this.clear();const e=this.ids[t];e&&this.state[e]&&(delete this.state[e][t],0===Object.keys(this.state[e]).length&&delete this.state[e],delete this.ids[t])}clear(){this.state={},this.ids={}}emit(t,e){if(this.state[t])for(const i of Object.keys(this.state[t])){const s=this.state[t][i];"function"==typeof s&&s(e)}}async emitSync(t,e){if(this.state[t])for(const i of Object.keys(this.state[t])){const s=this.state[t][i];if("function"==typeof s)try{await s(e)}catch(t){console.log(t)}}}clone(){return{state:{...this.state},ids:{...this.ids}}}restore(t){this.state=t.state,this.ids=t.ids}}class m extends f{_cache={};emit(t,e){this._cache[t]=e,super.emit(t,e)}getState(t){return this._cache[t]}}const p=t=>e=>{const i={};for(const s of Object.keys(e))i[s]=t(e[s],s);return i},g=async t=>{await new Promise((e=>{let i=setTimeout((()=>{e(),clearTimeout(i),i=null}),t)}))},y=async(t,e=1e4)=>new Promise((async(i,s)=>{let n=!1;const r=setTimeout((()=>{n=!0,s(new Error("Timeout"))}),e);let o;try{o=await t(),clearTimeout(r)}catch(t){console.log(t),clearTimeout(r),n||s(t)}n||i(o)})),d=(t,e)=>{let i=!0;return(async()=>{for(;i;){try{await t()}catch(t){console.log(t)}await g(e)}})(),()=>i=!1},w=(t,{checkTime:e,timeout:i}={})=>new Promise(((s,n)=>{let r,o=d((async()=>{const e=await t();e&&("function"==typeof o&&o(),r&&(clearTimeout(r),r=null),s(e),o=null,t=null,s=null)}),e||100);i&&(r=setTimeout((()=>{"function"==typeof o&&o(),r&&(clearTimeout(r),r=null),n("timeout"),n=null,o=null,t=null}),i))})),b=async(t,{times:e=5,interval:i=1e3}={times:5,interval:1e3})=>{let s=1;const n=async()=>{let r;if(s>e)throw new Error("retry times exceed");try{return r=await t(),r}catch(t){console.log(`action error, times ${s}`),console.log(t),await g(i),s+=1,await n()}};await n()};class M{times;interval;action;count=1;args=[];result;canceled=!1;constructor(t,{times:e=5,interval:i=1e3}={times:5,interval:1e3}){this.interval=i,this.times=e,this.action=t}async _run(){if(this.canceled)throw new Error("retry canceled");if(this.count>this.times)throw new Error("retry times exceed");try{this.result=await this.action(...this.args)}catch(t){console.log(`action error, times ${this.count}`),console.log(t),await g(this.interval),this.count+=1,await this._run()}}async run(...t){return this.canceled=!1,this.result=null,this.count=1,this.args=t,await this._run(),this.args=[],this.count=1,this.result}async cancel(){this.canceled=!0}}class x{cache=[];running=!1;len=0;async _run({fn:t,promise:e}){try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}t=null,e=null}async run(){if(this.cache.length<1)return void(this.running=!1);this.running=!0;const t=this.cache.shift();this.len-=1,"function"==typeof t.fn&&await this._run(t),this.run()}push(t){return this.len+=1,new Promise(((e,i)=>{this.cache.push({fn:t,promise:{resolve:e,reject:i}}),this.running||this.run()}))}get length(){return this.len}}const T=async(t,e=4)=>{let i=-1;const s=[],n=async()=>{if(i+=1,t[i]){try{await t[i]()}catch(t){console.log(t)}await n()}};for(let t=0;t<e;t+=1)s.push(n());await Promise.all(s)};function A(t,e){const i=new x;let s=[];return(...n)=>{if(s=n,!(i.length>0))return i.push((async()=>{await g(e),await t(...s)}))}}class _{timeout;_count=0;props;constructor(t){this.props=t}get count(){return this._count}increment(){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.clear()),this.props.resetTime),this._count=this._count+1,this._count>this.props.count&&this.props.cb()}clear(){clearTimeout(this.timeout),this._count=0,this.timeout=0}}const v=function(){const t={};for(let e=0;e<64;e++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;return t}();function E(t){const e=new Uint8Array(6*t.length/8);let i=0,s=0,n=0;for(let r=0;r<t.length&&n<e.length;r+=1)if(s=(s<<6)+v[t.charAt(r)],i+=6,i>=8){i-=8;let t=s>>>i;e[n++]=255&t,t<<=i,s-=t}return e}class S{stack=[];len=10;point=0;constructor(t=10){this.len=t}get current(){if(this.point<this.stack.length&&this.point>-1)return this.stack[this.point]}clear(){this.stack.length=0,this.point=0}backup(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()}undo(){return this.point<this.stack.length-1&&(this.point+=1),this.current}redo(){return this.point>0&&(this.point-=1),this.current}}class L{onTimeout;timeout=null;_time;constructor({limit:t=10,onTimeout:e}){this._time=1e3*t,this.onTimeout=()=>{this.timeout&&(clearTimeout(this.timeout),this.timeout=null),e()}}feed(){this.init()}init(){clearTimeout(this.timeout),this.timeout=null,delete this.timeout,this.timeout=setTimeout(this.onTimeout,this._time)}stop(){this.timeout&&clearTimeout(this.timeout),delete this.timeout}}class k{config;step;constructor(t){this.config=t,this.step=(this.config.max-this.config.min)/(this.config.count-2)}get(t){if(t<=this.config.min)return 1;if(t>=this.config.max)return this.config.count;for(let e=2,i=this.config.min+this.step;i<this.config.max+this.step;i+=this.step,e+=1)if(t<i)return e;return this.config.count}}const P=t=>(...e)=>new Promise(((i,s)=>{t(...e,((t,...e)=>{t&&s(t),e.length<2?i(e[0]):i([...e])})),t=null})),N=(t,e)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),R=t=>180*t/Math.PI,j=t=>t*Math.PI/180,O=({w:t,h:e})=>R(Math.atan2(e,t));function z(t,e=.5){if(t.length<3||e<=0)return t;let i;return t.filter(((s,n)=>!(n>0&&N(i,s)<e||(i=t[n],0))))}function C(t){const e=[0,0];for(const i of t)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 U(t,e,i){return i&&(e=j(e)),[Math.cos(e)*t[0]-Math.sin(e)*t[1],Math.sin(e)*t[0]+Math.cos(e)*t[1]]}const I=(t,e)=>{const i={x:e.x-t.x,y:e.y-t.y};return Math.atan2(i.y,i.x)},D=(t,e)=>{if(t.length<2)return 0;const i=[];let s=1/0,n=0;for(const r of t){const t=N(r,e),o=I(e,r)-e.theta;s>t&&(s=t),i.push({...r,index:n,distance:t,theta:o}),n+=1}return i.filter((t=>t.distance-s<.1)).sort(((t,e)=>t.theta-e.theta))[0].index},B=(t,e={x:0,y:0,theta:0})=>{let i=e;const s=[],n=[...t];for(;n.length>0;){const t=D(n,i);s.push(n[t]),i=n[t],n.splice(t,1)}return s},F=(t,e)=>Math.atan2(e.y,e.x)-Math.atan2(t.y,t.x),q=t=>t.split("_").map(((t,e)=>e>0?t.slice(0,1).toUpperCase()+t.slice(1):t)).join(""),X=(t,e=2)=>null==t||"NaN"===t?"N/A":("number"!=typeof t&&(t=parseFloat(t)),isNaN(t)?"N/A":t.toFixed(e));class W{list;_RegExpList=null;constructor(t){this.list=t}getRegEXP(t){const e=t.replace("/","\\/").replace("*",".*");return new RegExp(e)}include(t){return this._RegExpList||(this._RegExpList=this.list.map(this.getRegEXP)),this._RegExpList.some((e=>e.test(t)))}}class ${tmp=[];size;step;min;max;count=0;value=NaN;old;constructor({size:t=5,step:e=5,min:i=-1/0,max:s=1/0}={}){this.size=t,this.step=e,this.min=i,this.max=s,this.old=this.min}filter(t){return t<this.min||t>this.max||(this.tmp.push(t),this.old=this.calc(t)),this.old}calc(t){if(this.tmp.length<1)return t;this.tmp.length>this.size&&this.tmp.shift();const{res:e,dic:i}=this.getMostNumberOfTmp();return e!==t&&Math.abs(e-t)>this.step?(this.value!==t?this.count=1:this.count+=1,this.value=t,this.count>i[e]?(this.tmp.length=0,this.tmp.push(t),this.count=0,this.value=NaN,t):e):(this.count=0,this.value=NaN,t)}getMostNumberOfTmp(){const t={};let e,i=0;for(const s of this.tmp)t[s]?t[s]+=1:t[s]=1,t[s]>=i&&(i=t[s],e=s);return{res:e,dic:t}}}class H{_splitSymbol;_cache="";constructor(t){this._splitSymbol=t}split(t){const e=(this._cache+t).split(this._splitSymbol);return this._cache=e.splice(e.length-1,1)[0],e}}function K(t,e=new WeakMap){if("object"!=typeof t||null===t)return t;if(e.has(t))return e.get(t);if(Array.isArray(t)){const i=t.map((t=>K(t,e)));return e.set(t,i),i}if(t instanceof Set){const i=new Set([...t].map((t=>K(t,e))));return e.set(t,i),i}if(t instanceof Map){const i=new Map;for(const[s,n]of t.entries())i.set(K(s,e),K(n,e));return e.set(t,i),i}{const i={};e.set(t,i);for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=K(t[s],e));return i}}function Q(t,e){if(e.length<1)return null;let i;Array.isArray(t)&&(i={children:t});for(const t of e)i=i.children[t];return K(i)}function V(t,e,i="children"){const s=[];let n=!1;const r=t=>{for(let o=0;o<t.length;o+=1){const a=t[o];if(e(a)){n=!0,s.push(o);break}if(Array.isArray(a[i])){if(s.push(o),r(a[i]),n)break;s.pop()}}};return Array.isArray(t)?r(t):Array.isArray(t[i])&&r(t[i]),n?s:[]}const Z=(t,e="children",i=[],s=[])=>{let n=[];return Array.isArray(t[e])?n=t[e]:Array.isArray(t)&&(n=t),n.forEach(((t,n)=>{const r={...t};delete r[e],s.push(r),r.__indexes=[...i,n]})),n.forEach(((t,n)=>Z(t,e,[...i,n],s))),s},G=(t,e,i="children")=>{const s=[];let n=[];return Array.isArray(t[i])?n=t[i]:Array.isArray(t)&&(n=t),n.forEach((t=>{var n;t[i]&&(t[i]=G(t[i],e)),((null===(n=t[i])||void 0===n?void 0:n.length)>0||e(t))&&s.push(t)})),s},J=t=>{const e={};for(const i of Object.keys(t))e[t[i]]=i;return e},Y=.9996,tt=.00669438,et=Math.pow(tt,2),it=Math.pow(tt,3),st=tt/(1-tt),nt=Math.sqrt(1-tt),rt=(1-nt)/(1+nt),ot=Math.pow(rt,2),at=Math.pow(rt,3),ht=Math.pow(rt,4),ct=Math.pow(rt,5),ut=1-tt/4-3*et/64-5*it/256,lt=3*tt/8+3*et/32+45*it/1024,ft=15*et/256+45*it/1024,mt=35*it/3072,pt=1.5*rt-27/32*at+269/512*ct,gt=21/16*ot-55/32*ht,yt=151/96*at-417/128*ct,dt=1097/512*ht,wt=6378137,bt="CDEFGHJKLMNPQRSTUVWXX";function Mt(t){const{zoneNum:e,strict:i=!0}=t;let{zoneLetter:s,northern:n}=t;const r=t.x,o=t.y;if(!s&&void 0===n)throw new Error("either zoneLetter or northern needs to be set");if(s&&void 0!==n)throw new Error("set either zoneLetter or northern, but not both");if(i){if(r<1e5||1e6<=r)throw new RangeError("easting out of range (must be between 100 000 m and 999 999 m)");if(o<0||o>1e7)throw new RangeError("northing out of range (must be between 0 m and 10 000 000 m)")}if(e<1||e>60)throw new RangeError("zone number out of range (must be between 1 and 60)");if(s){if(s=s.toUpperCase(),1!==s.length||-1===bt.indexOf(s))throw new RangeError("zone letter out of range (must be between C and X)");n=s>="N"}const a=r-5e5;let h=o;n||(h-=1e7);const c=h/Y/(wt*ut),u=c+pt*Math.sin(2*c)+gt*Math.sin(4*c)+yt*Math.sin(6*c)+dt*Math.sin(8*c),l=Math.sin(u),f=Math.pow(l,2),m=Math.cos(u),p=Math.tan(u),g=Math.pow(p,2),y=Math.pow(p,4),d=1-tt*f,w=Math.sqrt(d),b=(1-tt)/d,M=rt*m*m,x=M*M,T=a/(wt/w*Y),A=Math.pow(T,2),_=Math.pow(T,3),v=Math.pow(T,4),E=Math.pow(T,5),S=Math.pow(T,6),L=(T-_/6*(1+2*g+M)+E/120*(5-2*M+28*g-3*x+8*st+24*y))/m;return{latitude:R(u-p/b*(A/2-v/24*(5+3*g+10*M-4*x-9*st))+S/720*(61+90*g+298*M+45*y-252*st-3*x)),longitude:R(L)+_t(e)}}function xt({latitude:t,longitude:e},i){if(t>84||t<-80)throw new RangeError("latitude out of range (must be between 80 deg S and 84 deg N)");if(e>180||e<-180)throw new RangeError("longitude out of range (must be between 180 deg W and 180 deg E)");const s=j(t),n=Math.sin(s),r=Math.cos(s),o=Math.tan(s),a=Math.pow(o,2),h=Math.pow(o,4);let c;c=void 0===i?At({latitude:t,longitude:e}):i;const u=Tt(t),l=j(e),f=_t(c),m=j(f),p=wt/Math.sqrt(1-tt*n*n),g=st*r*r,y=r*(l-m),d=Math.pow(y,2),w=Math.pow(y,3),b=Math.pow(y,4),M=Math.pow(y,5),x=Math.pow(y,6),T=wt*(ut*s-lt*Math.sin(2*s)+ft*Math.sin(4*s)-mt*Math.sin(6*s));let A=Y*(T+p*o*(d/2+b/24*(5-a+9*g+4*g*g)+x/720*(61-58*a+h+600*g-330*st)));return t<0&&(A+=1e7),{x:Y*p*(y+w/6*(1-a+g)+M/120*(5-18*a+h+72*g-58*st))+5e5,y:A,zoneNum:c,zoneLetter:u}}function Tt(t){return-80<=t&&t<=84?bt[Math.floor((t+80)/8)]:null}function At({latitude:t,longitude:e}){if(56<=t&&t<64&&3<=e&&e<12)return 32;if(72<=t&&t<=84&&e>=0){if(e<9)return 31;if(e<21)return 33;if(e<33)return 35;if(e<42)return 37}return Math.floor((e+180)/6)+1}function _t(t){return 6*(t-1)-180+3}class vt{cache=Buffer.alloc(0);c;constructor(t){this.c=t}push(t){const e=Buffer.concat([this.cache,t]),i=[];let s=0;for(let t=this.cache.byteLength;t<=e.byteLength-this.c.byteLength;t+=1)if(this.c.equals(e.subarray(t,this.c.byteLength+t))){const n=e.subarray(s,t);i.push(n),s=this.c.byteLength+t,t=this.c.byteLength+t}return this.cache=e.subarray(s),i}}return e})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PuboUtils=e():t.PuboUtils=e()}(this,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Base64Utils:()=>s,BufferSplit:()=>Rt,CacheEmitter:()=>p,ColorUtils:()=>c,ContinuousTrigger:()=>E,Emitter:()=>f,HistoryStack:()=>L,Level:()=>P,LinearColor:()=>l,RegExpList:()=>$,RemoteControl:()=>T,RemoteControlOptions:()=>i.RemoteControlOptions,RetryPlus:()=>x,SensorDataFilter:()=>H,StringSplit:()=>K,SyncQueue:()=>_,UTM:()=>n,WatchDog:()=>k,callbackToPromise:()=>N,cloneDeep:()=>Q,debounce:()=>r,degrees:()=>O,filterKeyPoints:()=>U,filterTree:()=>Y,fixNum:()=>W,flatTree:()=>J,getAngle:()=>z,getBestPointIndex:()=>B,getCenter:()=>D,getDistance:()=>j,getPositionTheta:()=>X,getRotate:()=>I,getTreeItem:()=>Z,getVectorTheta:()=>q,hex2rgb:()=>a,loop:()=>w,lower2camel:()=>V,orderByDistance:()=>F,radians:()=>C,random:()=>u,randomRangeNum:()=>m,reflection:()=>tt,retry:()=>M,runAsyncTasks:()=>A,searchTree:()=>G,sleep:()=>y,superFactory:()=>g,throttle:()=>v,timeout:()=>d,waitFor:()=>b});var i={};t.r(i),t.d(i,{fR:()=>T,VY:()=>x,VX:()=>w,XD:()=>M,X_:()=>b});var s={};t.r(s),t.d(s,{EncoderMap:()=>R,toUnit8Array:()=>S});var n={};t.r(n),t.d(n,{fromLatLon:()=>_t,latLonToZoneNumber:()=>vt,latitudeToZoneLetter:()=>At,toLatLon:()=>Tt});const r=(t,e,i=!1)=>{if(i){let i,s=!0;return(...n)=>{s&&(t(...n),s=!1),i&&clearTimeout(i),i=setTimeout((()=>{clearTimeout(i),s=!0,i=null}),e)}}{let i;return(...s)=>{i&&(clearTimeout(i),i=null),i=setTimeout((()=>{t(...s),clearTimeout(i),s=null,i=null}),e)}}},o=t=>parseInt(t.replace("#",""),16),a=t=>{let e;e="string"==typeof t?o(t):t;const i=e.toString(2).padStart(24,"0");return[parseInt(i.slice(0,8),2),parseInt(i.slice(8,16),2),parseInt(i.slice(16,24),2)]},h=t=>"#"+[0,1,2].map((e=>t[e].toString(16))).join("");class c{int;constructor(t){"number"==typeof t?this.int=t:"string"==typeof t?this.int=o(t):Array.isArray(t)&&(this.int=o(h(t)))}getRgbArray(){return a(this.int)}get rgb(){return`rba(${this.getRgbArray().join(", ")})`}get hex(){return h(this.getRgbArray())}toString(t="hex"){return"rgb"===t?this.rgb:this.hex}}class l{base=[255,0,0];intensity=1;min;max;constructor({base:t=[255,0,0],intensity:e=1}={}){this.base=t,this.intensity=e,this.intensity<1&&(this.intensity=1),this.min=this.base[1],this.max=this.base[0],Math.abs(this.min-this.max)<1&&(this.min=0,this.max=255)}getColor(t){if(t<0)return this.base;let e=this.base[0],i=this.base[1],s=this.base[2],n=t*this.intensity;return i=this.base[1]+n,i<this.max||(n=i-this.max,i=this.max,e=this.base[0]-n,e>this.min||(n=this.min-e,e=this.min,s=this.base[2]+n,s<this.max||(n=s-this.max,s=this.max,i-=n,i>this.min||(n=this.min-i,i=this.min,e+=n,e<this.max||(n=e-this.max,e=this.max,s-=n,s>this.min||(s=this.min)))))),[e,i,s]}}const u=(t=8)=>{const e=t=>Math.random().toString(32).slice(2,2+t);if(t<=8)return e(t);let i="";for(let s=0;s<=t;s+=8)i+=e(t-s>8?8:t-s);return i},m=t=>{const e=Math.abs(t[1]-t[0]);return Math.random()*e+Math.min(...t)};class f{state={};ids={};on(t,e){if(this.state[t]||(this.state[t]={}),"function"!=typeof e)throw new Error("第二个参数必须为function!");const i=`${u(40)}_${(new Date).valueOf()}`;return this.state[t][i]=e,this.ids[i]=t,i}cancel(t){if(!t)return void this.clear();const e=this.ids[t];e&&this.state[e]&&(delete this.state[e][t],0===Object.keys(this.state[e]).length&&delete this.state[e],delete this.ids[t])}clear(){this.state={},this.ids={}}emit(t,e){if(this.state[t])for(const i of Object.keys(this.state[t])){const s=this.state[t][i];"function"==typeof s&&s(e)}}async emitSync(t,e){if(this.state[t])for(const i of Object.keys(this.state[t])){const s=this.state[t][i];if("function"==typeof s)try{await s(e)}catch(t){console.log(t)}}}clone(){return{state:{...this.state},ids:{...this.ids}}}restore(t){this.state=t.state,this.ids=t.ids}}class p extends f{_cache={};emit(t,e){this._cache[t]=e,super.emit(t,e)}getState(t){return this._cache[t]}}const g=t=>e=>{const i={};for(const s of Object.keys(e))i[s]=t(e[s],s);return i},y=async t=>{await new Promise((e=>{let i=setTimeout((()=>{e(),clearTimeout(i),i=null}),t)}))},d=async(t,e=1e4)=>new Promise((async(i,s)=>{let n=!1;const r=setTimeout((()=>{n=!0,s(new Error("Timeout"))}),e);let o;try{o=await t(),clearTimeout(r)}catch(t){console.log(t),clearTimeout(r),n||s(t)}n||i(o)})),w=(t,e)=>{let i=!0;return(async()=>{for(;i;){try{await t()}catch(t){console.log(t)}await y(e)}})(),()=>i=!1},b=(t,{checkTime:e,timeout:i}={})=>new Promise(((s,n)=>{let r,o=w((async()=>{const e=await t();e&&("function"==typeof o&&o(),r&&(clearTimeout(r),r=null),s(e),o=null,t=null,s=null)}),e||100);i&&(r=setTimeout((()=>{"function"==typeof o&&o(),r&&(clearTimeout(r),r=null),n("timeout"),n=null,o=null,t=null}),i))})),M=async(t,{times:e=5,interval:i=1e3}={times:5,interval:1e3})=>{let s=1;const n=async()=>{let r;if(s>e)throw new Error("retry times exceed");try{return r=await t(),r}catch(t){console.log(`action error, times ${s}`),console.log(t),await y(i),s+=1,await n()}};await n()};class x{times;interval;action;count=1;args=[];result;canceled=!1;constructor(t,{times:e=5,interval:i=1e3}={times:5,interval:1e3}){this.interval=i,this.times=e,this.action=t}async _run(){if(this.canceled)throw new Error("retry canceled");if(this.count>this.times)throw new Error("retry times exceed");try{this.result=await this.action(...this.args)}catch(t){console.log(`action error, times ${this.count}`),console.log(t),await y(this.interval),this.count+=1,await this._run()}}async run(...t){return this.canceled=!1,this.result=null,this.count=1,this.args=t,await this._run(),this.args=[],this.count=1,this.result}async cancel(){this.canceled=!0}}class T{timeout;_start;_stop;fps;payload;constructor({start:t,stop:e,fps:i=5}){this._start=t,this._stop=e,this.fps=i}send(){this.payload&&this._start(this.payload)}control(t){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.payload=t,this.send(),this.timeout=setTimeout((()=>this.stop()),1e3/this.fps)}stop(){this.payload=null,clearTimeout(this.timeout),this.timeout=null,this._stop()}}class _{cache=[];running=!1;len=0;async _run({fn:t,promise:e}){try{const i=await t();e.resolve(i)}catch(t){e.reject(t)}t=null,e=null}async run(){if(this.cache.length<1)return void(this.running=!1);this.running=!0;const t=this.cache.shift();this.len-=1,"function"==typeof t.fn&&await this._run(t),this.run()}push(t){return this.len+=1,new Promise(((e,i)=>{this.cache.push({fn:t,promise:{resolve:e,reject:i}}),this.running||this.run()}))}get length(){return this.len}}const A=async(t,e=4)=>{let i=-1;const s=[],n=async()=>{if(i+=1,t[i]){try{await t[i]()}catch(t){console.log(t)}await n()}};for(let t=0;t<e;t+=1)s.push(n());await Promise.all(s)};function v(t,e){const i=new _;let s=[];return(...n)=>{if(s=n,!(i.length>0))return i.push((async()=>{await y(e),await t(...s)}))}}class E{timeout;_count=0;props;constructor(t){this.props=t}get count(){return this._count}increment(){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.clear()),this.props.resetTime),this._count=this._count+1,this._count>this.props.count&&this.props.cb()}clear(){clearTimeout(this.timeout),this._count=0,this.timeout=0}}const R=function(){const t={};for(let e=0;e<64;e++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;return t}();function S(t){const e=new Uint8Array(6*t.length/8);let i=0,s=0,n=0;for(let r=0;r<t.length&&n<e.length;r+=1)if(s=(s<<6)+R[t.charAt(r)],i+=6,i>=8){i-=8;let t=s>>>i;e[n++]=255&t,t<<=i,s-=t}return e}class L{stack=[];len=10;point=0;constructor(t=10){this.len=t}get current(){if(this.point<this.stack.length&&this.point>-1)return this.stack[this.point]}clear(){this.stack.length=0,this.point=0}backup(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()}undo(){return this.point<this.stack.length-1&&(this.point+=1),this.current}redo(){return this.point>0&&(this.point-=1),this.current}}class k{onTimeout;timeout=null;_time;constructor({limit:t=10,onTimeout:e}){this._time=1e3*t,this.onTimeout=()=>{this.timeout&&(clearTimeout(this.timeout),this.timeout=null),e()}}feed(){this.init()}init(){clearTimeout(this.timeout),this.timeout=null,delete this.timeout,this.timeout=setTimeout(this.onTimeout,this._time)}stop(){this.timeout&&clearTimeout(this.timeout),delete this.timeout}}class P{config;step;constructor(t){this.config=t,this.step=(this.config.max-this.config.min)/(this.config.count-2)}get(t){if(t<=this.config.min)return 1;if(t>=this.config.max)return this.config.count;for(let e=2,i=this.config.min+this.step;i<this.config.max+this.step;i+=this.step,e+=1)if(t<i)return e;return this.config.count}}const N=t=>(...e)=>new Promise(((i,s)=>{t(...e,((t,...e)=>{t&&s(t),e.length<2?i(e[0]):i([...e])})),t=null})),j=(t,e)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),O=t=>180*t/Math.PI,C=t=>t*Math.PI/180,z=({w:t,h:e})=>O(Math.atan2(e,t));function U(t,e=.5){if(t.length<3||e<=0)return t;let i;return t.filter(((s,n)=>!(n>0&&j(i,s)<e||(i=t[n],0))))}function D(t){const e=[0,0];for(const i of t)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 I(t,e,i){return i&&(e=C(e)),[Math.cos(e)*t[0]-Math.sin(e)*t[1],Math.sin(e)*t[0]+Math.cos(e)*t[1]]}const X=(t,e)=>{const i={x:e.x-t.x,y:e.y-t.y};return Math.atan2(i.y,i.x)},B=(t,e)=>{if(t.length<2)return 0;const i=[];let s=1/0,n=0;for(const r of t){const t=j(r,e),o=X(e,r)-e.theta;s>t&&(s=t),i.push({...r,index:n,distance:t,theta:o}),n+=1}return i.filter((t=>t.distance-s<.1)).sort(((t,e)=>t.theta-e.theta))[0].index},F=(t,e={x:0,y:0,theta:0})=>{let i=e;const s=[],n=[...t];for(;n.length>0;){const t=B(n,i);s.push(n[t]),i=n[t],n.splice(t,1)}return s},q=(t,e)=>Math.atan2(e.y,e.x)-Math.atan2(t.y,t.x),V=t=>t.split("_").map(((t,e)=>e>0?t.slice(0,1).toUpperCase()+t.slice(1):t)).join(""),W=(t,e=2)=>null==t||"NaN"===t?"N/A":("number"!=typeof t&&(t=parseFloat(t)),isNaN(t)?"N/A":t.toFixed(e));class ${list;_RegExpList=null;constructor(t){this.list=t}getRegEXP(t){const e=t.replace("/","\\/").replace("*",".*");return new RegExp(e)}include(t){return this._RegExpList||(this._RegExpList=this.list.map(this.getRegEXP)),this._RegExpList.some((e=>e.test(t)))}}class H{tmp=[];size;step;min;max;count=0;value=NaN;old;constructor({size:t=5,step:e=5,min:i=-1/0,max:s=1/0}={}){this.size=t,this.step=e,this.min=i,this.max=s,this.old=this.min}filter(t){return t<this.min||t>this.max||(this.tmp.push(t),this.old=this.calc(t)),this.old}calc(t){if(this.tmp.length<1)return t;this.tmp.length>this.size&&this.tmp.shift();const{res:e,dic:i}=this.getMostNumberOfTmp();return e!==t&&Math.abs(e-t)>this.step?(this.value!==t?this.count=1:this.count+=1,this.value=t,this.count>i[e]?(this.tmp.length=0,this.tmp.push(t),this.count=0,this.value=NaN,t):e):(this.count=0,this.value=NaN,t)}getMostNumberOfTmp(){const t={};let e,i=0;for(const s of this.tmp)t[s]?t[s]+=1:t[s]=1,t[s]>=i&&(i=t[s],e=s);return{res:e,dic:t}}}class K{_splitSymbol;_cache="";constructor(t){this._splitSymbol=t}split(t){const e=(this._cache+t).split(this._splitSymbol);return this._cache=e.splice(e.length-1,1)[0],e}}function Q(t,e=new WeakMap){if("object"!=typeof t||null===t)return t;if(e.has(t))return e.get(t);if(Array.isArray(t)){const i=t.map((t=>Q(t,e)));return e.set(t,i),i}if(t instanceof Set){const i=new Set([...t].map((t=>Q(t,e))));return e.set(t,i),i}if(t instanceof Map){const i=new Map;for(const[s,n]of t.entries())i.set(Q(s,e),Q(n,e));return e.set(t,i),i}{const i={};e.set(t,i);for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=Q(t[s],e));return i}}function Z(t,e){if(e.length<1)return null;let i;Array.isArray(t)&&(i={children:t});for(const t of e)i=i.children[t];return Q(i)}function G(t,e,i="children"){const s=[];let n=!1;const r=t=>{for(let o=0;o<t.length;o+=1){const a=t[o];if(e(a)){n=!0,s.push(o);break}if(Array.isArray(a[i])){if(s.push(o),r(a[i]),n)break;s.pop()}}};return Array.isArray(t)?r(t):Array.isArray(t[i])&&r(t[i]),n?s:[]}const J=(t,e="children",i=[],s=[])=>{let n=[];return Array.isArray(t[e])?n=t[e]:Array.isArray(t)&&(n=t),n.forEach(((t,n)=>{const r={...t};delete r[e],s.push(r),r.__indexes=[...i,n]})),n.forEach(((t,n)=>J(t,e,[...i,n],s))),s},Y=(t,e,i="children")=>{const s=[];let n=[];return Array.isArray(t[i])?n=t[i]:Array.isArray(t)&&(n=t),n.forEach((t=>{var n;t[i]&&(t[i]=Y(t[i],e)),((null===(n=t[i])||void 0===n?void 0:n.length)>0||e(t))&&s.push(t)})),s},tt=t=>{const e={};for(const i of Object.keys(t))e[t[i]]=i;return e},et=.9996,it=.00669438,st=Math.pow(it,2),nt=Math.pow(it,3),rt=it/(1-it),ot=Math.sqrt(1-it),at=(1-ot)/(1+ot),ht=Math.pow(at,2),ct=Math.pow(at,3),lt=Math.pow(at,4),ut=Math.pow(at,5),mt=1-it/4-3*st/64-5*nt/256,ft=3*it/8+3*st/32+45*nt/1024,pt=15*st/256+45*nt/1024,gt=35*nt/3072,yt=1.5*at-27/32*ct+269/512*ut,dt=21/16*ht-55/32*lt,wt=151/96*ct-417/128*ut,bt=1097/512*lt,Mt=6378137,xt="CDEFGHJKLMNPQRSTUVWXX";function Tt(t){const{zoneNum:e,strict:i=!0}=t;let{zoneLetter:s,northern:n}=t;const r=t.x,o=t.y;if(!s&&void 0===n)throw new Error("either zoneLetter or northern needs to be set");if(s&&void 0!==n)throw new Error("set either zoneLetter or northern, but not both");if(i){if(r<1e5||1e6<=r)throw new RangeError("easting out of range (must be between 100 000 m and 999 999 m)");if(o<0||o>1e7)throw new RangeError("northing out of range (must be between 0 m and 10 000 000 m)")}if(e<1||e>60)throw new RangeError("zone number out of range (must be between 1 and 60)");if(s){if(s=s.toUpperCase(),1!==s.length||-1===xt.indexOf(s))throw new RangeError("zone letter out of range (must be between C and X)");n=s>="N"}const a=r-5e5;let h=o;n||(h-=1e7);const c=h/et/(Mt*mt),l=c+yt*Math.sin(2*c)+dt*Math.sin(4*c)+wt*Math.sin(6*c)+bt*Math.sin(8*c),u=Math.sin(l),m=Math.pow(u,2),f=Math.cos(l),p=Math.tan(l),g=Math.pow(p,2),y=Math.pow(p,4),d=1-it*m,w=Math.sqrt(d),b=(1-it)/d,M=at*f*f,x=M*M,T=a/(Mt/w*et),_=Math.pow(T,2),A=Math.pow(T,3),v=Math.pow(T,4),E=Math.pow(T,5),R=Math.pow(T,6),S=(T-A/6*(1+2*g+M)+E/120*(5-2*M+28*g-3*x+8*rt+24*y))/f;return{latitude:O(l-p/b*(_/2-v/24*(5+3*g+10*M-4*x-9*rt))+R/720*(61+90*g+298*M+45*y-252*rt-3*x)),longitude:O(S)+Et(e)}}function _t({latitude:t,longitude:e},i){if(t>84||t<-80)throw new RangeError("latitude out of range (must be between 80 deg S and 84 deg N)");if(e>180||e<-180)throw new RangeError("longitude out of range (must be between 180 deg W and 180 deg E)");const s=C(t),n=Math.sin(s),r=Math.cos(s),o=Math.tan(s),a=Math.pow(o,2),h=Math.pow(o,4);let c;c=void 0===i?vt({latitude:t,longitude:e}):i;const l=At(t),u=C(e),m=Et(c),f=C(m),p=Mt/Math.sqrt(1-it*n*n),g=rt*r*r,y=r*(u-f),d=Math.pow(y,2),w=Math.pow(y,3),b=Math.pow(y,4),M=Math.pow(y,5),x=Math.pow(y,6),T=Mt*(mt*s-ft*Math.sin(2*s)+pt*Math.sin(4*s)-gt*Math.sin(6*s));let _=et*(T+p*o*(d/2+b/24*(5-a+9*g+4*g*g)+x/720*(61-58*a+h+600*g-330*rt)));return t<0&&(_+=1e7),{x:et*p*(y+w/6*(1-a+g)+M/120*(5-18*a+h+72*g-58*rt))+5e5,y:_,zoneNum:c,zoneLetter:l}}function At(t){return-80<=t&&t<=84?xt[Math.floor((t+80)/8)]:null}function vt({latitude:t,longitude:e}){if(56<=t&&t<64&&3<=e&&e<12)return 32;if(72<=t&&t<=84&&e>=0){if(e<9)return 31;if(e<21)return 33;if(e<33)return 35;if(e<42)return 37}return Math.floor((e+180)/6)+1}function Et(t){return 6*(t-1)-180+3}class Rt{cache=Buffer.alloc(0);c;constructor(t){this.c=t}push(t){const e=Buffer.concat([this.cache,t]),i=[];let s=0;for(let t=this.cache.byteLength;t<=e.byteLength-this.c.byteLength;t+=1)if(this.c.equals(e.subarray(t,this.c.byteLength+t))){const n=e.subarray(s,t);i.push(n),s=this.c.byteLength+t,t=this.c.byteLength+t}return this.cache=e.subarray(s),i}}return e})()));
package/es/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { debounce } from './debounce';
2
2
  export { hex2rgb, LinearColor, ColorUtils } from './color/utils';
3
3
  export { Emitter, CacheEmitter } from './emitter';
4
4
  export { superFactory } from './factory';
5
- export { loop, retry, waitFor, RetryPlus } from './loop';
5
+ export { loop, retry, waitFor, RetryPlus, RemoteControl, RemoteControlOptions } from './loop';
6
6
  export { SyncQueue, runAsyncTasks } from './queue';
7
7
  export { random, randomRangeNum } from './random';
8
8
  export { sleep, timeout } from './sleep';
package/es/index.js CHANGED
@@ -2,7 +2,7 @@ export { debounce } from './debounce';
2
2
  export { hex2rgb, LinearColor, ColorUtils } from './color/utils';
3
3
  export { Emitter, CacheEmitter } from './emitter';
4
4
  export { superFactory } from './factory';
5
- export { loop, retry, waitFor, RetryPlus } from './loop';
5
+ export { loop, retry, waitFor, RetryPlus, RemoteControl, RemoteControlOptions } from './loop';
6
6
  export { SyncQueue, runAsyncTasks } from './queue';
7
7
  export { random, randomRangeNum } from './random';
8
8
  export { sleep, timeout } from './sleep';
@@ -40,4 +40,24 @@ export declare class RetryPlus {
40
40
  run(...args: any[]): Promise<any>;
41
41
  cancel(): Promise<void>;
42
42
  }
43
+ export interface RemoteControlOptions {
44
+ start: (payload?: any) => void;
45
+ stop: (payload?: any) => void;
46
+ fps?: number;
47
+ }
48
+ export declare class RemoteControl {
49
+ private timeout;
50
+ private _start;
51
+ private _stop;
52
+ private readonly fps;
53
+ private payload;
54
+ constructor({ start, stop, fps }: {
55
+ start: any;
56
+ stop: any;
57
+ fps?: number | undefined;
58
+ });
59
+ private send;
60
+ control(payload: any): void;
61
+ stop(): void;
62
+ }
43
63
  export {};
package/es/loop/index.js CHANGED
@@ -134,3 +134,34 @@ export class RetryPlus {
134
134
  this.canceled = true;
135
135
  }
136
136
  }
137
+ export class RemoteControl {
138
+ timeout;
139
+ _start;
140
+ _stop;
141
+ fps;
142
+ payload;
143
+ constructor({ start, stop, fps = 5 }){
144
+ this._start = start;
145
+ this._stop = stop;
146
+ this.fps = fps;
147
+ }
148
+ send() {
149
+ if (!this.payload) return;
150
+ this._start(this.payload);
151
+ }
152
+ control(payload) {
153
+ if (this.timeout) {
154
+ clearTimeout(this.timeout);
155
+ this.timeout = null;
156
+ }
157
+ this.payload = payload;
158
+ this.send();
159
+ this.timeout = setTimeout(()=>this.stop(), 1000 / this.fps);
160
+ }
161
+ stop() {
162
+ this.payload = null;
163
+ clearTimeout(this.timeout);
164
+ this.timeout = null;
165
+ this._stop();
166
+ }
167
+ }
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { debounce } from './debounce';
2
2
  export { hex2rgb, LinearColor, ColorUtils } from './color/utils';
3
3
  export { Emitter, CacheEmitter } from './emitter';
4
4
  export { superFactory } from './factory';
5
- export { loop, retry, waitFor, RetryPlus } from './loop';
5
+ export { loop, retry, waitFor, RetryPlus, RemoteControl, RemoteControlOptions } from './loop';
6
6
  export { SyncQueue, runAsyncTasks } from './queue';
7
7
  export { random, randomRangeNum } from './random';
8
8
  export { sleep, timeout } from './sleep';
package/lib/index.js CHANGED
@@ -39,6 +39,12 @@ _export(exports, {
39
39
  RegExpList: function() {
40
40
  return _regexplist.RegExpList;
41
41
  },
42
+ RemoteControl: function() {
43
+ return _loop.RemoteControl;
44
+ },
45
+ RemoteControlOptions: function() {
46
+ return _loop.RemoteControlOptions;
47
+ },
42
48
  RetryPlus: function() {
43
49
  return _loop.RetryPlus;
44
50
  },
@@ -40,4 +40,24 @@ export declare class RetryPlus {
40
40
  run(...args: any[]): Promise<any>;
41
41
  cancel(): Promise<void>;
42
42
  }
43
+ export interface RemoteControlOptions {
44
+ start: (payload?: any) => void;
45
+ stop: (payload?: any) => void;
46
+ fps?: number;
47
+ }
48
+ export declare class RemoteControl {
49
+ private timeout;
50
+ private _start;
51
+ private _stop;
52
+ private readonly fps;
53
+ private payload;
54
+ constructor({ start, stop, fps }: {
55
+ start: any;
56
+ stop: any;
57
+ fps?: number | undefined;
58
+ });
59
+ private send;
60
+ control(payload: any): void;
61
+ stop(): void;
62
+ }
43
63
  export {};
package/lib/loop/index.js CHANGED
@@ -9,6 +9,9 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ RemoteControl: function() {
13
+ return RemoteControl;
14
+ },
12
15
  RetryPlus: function() {
13
16
  return RetryPlus;
14
17
  },
@@ -144,3 +147,34 @@ class RetryPlus {
144
147
  this.canceled = true;
145
148
  }
146
149
  }
150
+ class RemoteControl {
151
+ timeout;
152
+ _start;
153
+ _stop;
154
+ fps;
155
+ payload;
156
+ constructor({ start, stop, fps = 5 }){
157
+ this._start = start;
158
+ this._stop = stop;
159
+ this.fps = fps;
160
+ }
161
+ send() {
162
+ if (!this.payload) return;
163
+ this._start(this.payload);
164
+ }
165
+ control(payload) {
166
+ if (this.timeout) {
167
+ clearTimeout(this.timeout);
168
+ this.timeout = null;
169
+ }
170
+ this.payload = payload;
171
+ this.send();
172
+ this.timeout = setTimeout(()=>this.stop(), 1000 / this.fps);
173
+ }
174
+ stop() {
175
+ this.payload = null;
176
+ clearTimeout(this.timeout);
177
+ this.timeout = null;
178
+ this._stop();
179
+ }
180
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-utils",
3
- "version": "1.0.192",
3
+ "version": "1.0.194",
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": "5916cce8a7b16eb69c0770a2075f1e7b1dcc1f85",
21
+ "gitHead": "7c789085970e09fe147a152b164a5f95397da92d",
22
22
  "devDependencies": {
23
23
  "del": "^5.1.0",
24
24
  "eslint": "^8.42.0",