pubo-utils 1.0.129 → 1.0.142

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:()=>M,Emitter:()=>d,HistoryStack:()=>I,Level:()=>L,RegExpList:()=>Z,SensorDataFilter:()=>$,StringSplit:()=>tt,SyncQueue:()=>_,WatchDog:()=>N,callbackToPromise:()=>G,debounce:()=>u,degrees:()=>F,filterKeyPoints:()=>H,getAngle:()=>q,getBestPointIndex:()=>W,getCenter:()=>K,getDistance:()=>B,getPositionTheta:()=>V,getRotate:()=>Q,getVectorTheta:()=>Y,hex2rgb:()=>c,loop:()=>S,lower2camel:()=>nt,orderByDistance:()=>J,radians:()=>X,random:()=>f,randomRangeNum:()=>h,sleep:()=>m,superFactory:()=>g,throttle:()=>P,waitFor:()=>T});var e={};t.r(e),t.d(e,{EncoderMap:()=>E,toUnit8Array:()=>R});var r,o=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},i=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))},u=function(t,n,e){if(void 0===e&&(e=!1),e){var r,u=!0;return function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];u&&(t.apply(void 0,i([],o(e),!1)),u=!1),r&&clearTimeout(r),r=setTimeout((function(){return u=!0}),n)}}var a;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];a&&clearTimeout(a),a=setTimeout((function(){return t.apply(void 0,i([],o(e),!1))}),n)}},a=function(t){return parseInt(t.replace("#",""),16)},c=function(t){var n=("string"==typeof t?a(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)]},l=function(t){return"#"+[0,1,2].map((function(n){return t[n].toString(16)})).join("")},s=(function(){function t(t){"number"==typeof t?this.int=t:"string"==typeof t?this.int=a(t):Array.isArray(t)&&(this.int=a(l(t)))}t.prototype.getRgbArray=function(){return c(this.int)},Object.defineProperty(t.prototype,"rgb",{get:function(){return"rba(".concat(this.getRgbArray().join(", "),")")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hex",{get:function(){return l(this.getRgbArray())},enumerable:!1,configurable:!0}),t.prototype.toString=function(t){return void 0===t&&(t="hex"),"rgb"===t?this.rgb:this.hex}}(),function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}),f=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},h=function(t){var n=Math.abs(t[1]-t[0]);return Math.random()*n+Math.min.apply(Math,function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([],s(t),!1))},p=(r=function(t,n){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},r(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),y=function(){return y=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},y.apply(this,arguments)},v=function(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},d=function(){function t(){this.state={},this.ids={}}return t.prototype.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=f(40);return this.ids[r]={event:t,index:e},r},t.prototype.cancel=function(t){var n=this;if(t){var e=this.ids[t]||{},r=e.event,o=e.index;r&&Array.isArray(this.state[r])&&(this.state[r].splice(o,1),delete this.ids[t],Object.keys(this.ids).forEach((function(t){n.ids[t].event===r&&n.ids[t].index>o&&(n.ids[t].index=n.ids[t].index-1)})))}else this.clear()},t.prototype.clear=function(){this.state.length=0},t.prototype.emit=function(t,n){var e,r;if(Array.isArray(this.state[t]))try{for(var o=v(this.state[t]),i=o.next();!i.done;i=o.next()){var u=i.value;"function"==typeof u&&u(n)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}},t.prototype.emitSync=function(t,n){return e=this,r=void 0,i=function(){var e,r,o,i,u,a;return function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(t,u)}catch(t){a=[6,t],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(c){switch(c.label){case 0:if(!Array.isArray(this.state[t]))return[3,8];c.label=1;case 1:c.trys.push([1,6,7,8]),e=v(this.state[t]),r=e.next(),c.label=2;case 2:return r.done?[3,5]:"function"!=typeof(o=r.value)?[3,4]:[4,o(n)];case 3:c.sent(),c.label=4;case 4:return r=e.next(),[3,2];case 5:return[3,8];case 6:return i=c.sent(),u={error:i},[3,8];case 7:try{r&&!r.done&&(a=e.return)&&a.call(e)}finally{if(u)throw u.error}return[7];case 8:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,n){function u(t){try{c(i.next(t))}catch(t){n(t)}}function a(t){try{c(i.throw(t))}catch(t){n(t)}}function c(n){var e;n.done?t(n.value):(e=n.value,e instanceof o?e:new o((function(t){t(e)}))).then(u,a)}c((i=i.apply(e,r||[])).next())}));var e,r,o,i},t.prototype.clone=function(){return{state:y({},this.state),ids:y({},this.ids)}},t.prototype.restore=function(t){this.state=t.state,this.ids=t.ids},t}(),b=(function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n._cache={},n}p(n,t),n.prototype.emit=function(n,e){this._cache[n]=e,t.prototype.emit.call(this,n,e)},n.prototype.getState=function(t){return this._cache[t]}}(d),function(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}),g=function(t){return function(n){var e,r,o={};try{for(var i=b(Object.keys(n)),u=i.next();!u.done;u=i.next()){var a=u.value;o[a]=t(n[a],a)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return o}},m=function(t){return n=void 0,e=void 0,o=function(){return function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(t,u)}catch(t){a=[6,t],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n){return setTimeout((function(){return n()}),t)}))];case 1:return n.sent(),[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function u(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(n){var e;n.done?t(n.value):(e=n.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}c((o=o.apply(n,e||[])).next())}));var n,e,r,o},w=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,a)}c((r=r.apply(t,n||[])).next())}))},x=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(t,u)}catch(t){a=[6,t],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},S=function(t,n){var e=!0,r=function(){e=!1},o=function(){return w(void 0,void 0,void 0,(function(){return x(this,(function(i){switch(i.label){case 0:return[4,t(r)];case 1:return i.sent(),[4,m(n)];case 2:return i.sent(),e?o():o=null,[2]}}))}))};return o(),r},T=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,o=e.timeout;return new Promise((function(n,e){var i=S((function(){return w(void 0,void 0,void 0,(function(){var e;return x(this,(function(r){switch(r.label){case 0:return[4,t()];case 1:return(e=r.sent())&&(i(),n(e)),[2]}}))}))}),r||100);o&&setTimeout((function(){i(),e("timeout")}),o)}))},k=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,a)}c((r=r.apply(t,n||[])).next())}))},j=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(t,u)}catch(t){a=[6,t],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},_=function(){function t(){this.cache=[],this.running=!1,this.len=0}return t.prototype._run=function(t){var n=t.fn,e=t.promise;return k(this,void 0,void 0,(function(){var t,r;return j(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,n()];case 1:return t=o.sent(),e.resolve(t),[3,3];case 2:return r=o.sent(),e.reject(r),[3,3];case 3:return[2]}}))}))},t.prototype.run=function(){return k(this,void 0,void 0,(function(){var t;return j(this,(function(n){switch(n.label){case 0:return this.cache.length<1?(this.running=!1,[2]):(this.running=!0,t=this.cache.shift(),this.len-=1,"function"!=typeof t.fn?[3,2]:[4,this._run(t)]);case 1:n.sent(),n.label=2;case 2:return this.run(),[2]}}))}))},t.prototype.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()}))},Object.defineProperty(t.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),t}(),A=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},O=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))};function P(t,n){var e,r=!0;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];e||(e=setTimeout((function(){r=!0,e=null}),n)),r&&(r=!1,t.apply(void 0,O([],A(o),!1)))}}var M=function(){function t(t){this._count=0,this.props=t}return Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),t.prototype.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()},t.prototype.clear=function(){this._count=0},t}(),E=function(){for(var t={},n=0;n<64;n++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n)]=n;return t}();function R(t){for(var n=new Uint8Array(6*t.length/8),e=0,r=0,o=0,i=0;i<t.length&&o<n.length;i+=1)if(r=(r<<6)+E[t.charAt(i)],(e+=6)>=8){var u=r>>>(e-=8);n[o++]=255&u,r-=u<<=e}return n}var I=function(){function t(t){void 0===t&&(t=10),this.stack=[],this.len=10,this.point=0,this.len=t}return Object.defineProperty(t.prototype,"current",{get:function(){if(this.point<this.stack.length&&this.point>-1)return this.stack[this.point]},enumerable:!1,configurable:!0}),t.prototype.clear=function(){this.stack.length=0,this.point=0},t.prototype.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()},t.prototype.undo=function(){return this.point<this.stack.length-1&&(this.point+=1),this.current},t.prototype.redo=function(){return this.point>0&&(this.point-=1),this.current},t}(),N=function(){function t(t){var n=t.limit,e=void 0===n?10:n,r=t.onTimeout;this.limit=10,this.timeout=null,this.limit=e,this.onTimeout=r}return t.prototype.feed=function(){this.init()},t.prototype.init=function(){var t=this;clearTimeout(this.timeout),this.timeout=setTimeout((function(){return t.onTimeout()}),1e3*this.limit)},t.prototype.stop=function(){this.timeout&&clearTimeout(this.timeout)},t}(),L=function(){function t(t){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}(),C=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},D=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))},G=function(t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return new Promise((function(e,r){t.apply(void 0,D(D([],C(n),!1),[function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];t&&r(t),n.length<2?e(n[0]):e(D([],C(n),!1))}],!1))}))}},U=function(){return U=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},U.apply(this,arguments)},z=function(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},B=function(t,n){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))},F=function(t){return 180*t/Math.PI},X=function(t){return t*Math.PI/180},q=function(t){var n=t.w,e=t.h;return F(Math.atan2(e,n))};function H(t,n){return void 0===n&&(n=.5),t.length<3||n<=0?t:t.filter((function(r,o){return!(o>0&&B(e,r)<n||(e=t[o],0))}));var e}function K(t){var n,e,r=[0,0];try{for(var o=z(t),i=o.next();!i.done;i=o.next()){var u=i.value;Array.isArray(u)?(r[0]+=u[0],r[1]+=u[1]):(r[0]+=u.x,r[1]+=u.y)}}catch(t){n={error:t}}finally{try{i&&!i.done&&(e=o.return)&&e.call(o)}finally{if(n)throw n.error}}return{x:r[0]/t.length,y:r[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){var e,r;if(t.length<2)return 0;var o=[],i=1/0,u=0;try{for(var a=z(t),c=a.next();!c.done;c=a.next()){var l=c.value,s=B(l,n),f=V(n,l)-n.theta;i>s&&(i=s),o.push(U(U({},l),{index:u,distance:s,theta:f})),u+=1}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}var h=o.filter((function(t){return t.distance-i<.1})).sort((function(t,n){return t.theta-n.theta}));return h[0].index},J=function(t,n){void 0===n&&(n={x:0,y:0,theta:0});for(var e=n,r=[],o=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([],function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}(t),!1);o.length>0;){var i=W(o,e);r.push(o[i]),e=o[i],o.splice(i,1)}return r},Y=function(t,n){return Math.atan2(n.y,n.x)-Math.atan2(t.y,t.x)},Z=function(){function t(t){this._RegExpList=null,this.list=t}return t.prototype.getRegEXP=function(t){var n=t.replace("/","\\/").replace("*",".*");return new RegExp(n)},t.prototype.include=function(t){return this._RegExpList||(this._RegExpList=this.list.map(this.getRegEXP)),this._RegExpList.some((function(n){return n.test(t)}))},t}(),$=function(){function t(t){var n=void 0===t?{}:t,e=n.size,r=void 0===e?5:e,o=n.step,i=void 0===o?5:o,u=n.min,a=void 0===u?-1/0:u,c=n.max,l=void 0===c?1/0:c;this.tmp=[],this.count=0,this.value=NaN,this.size=r,this.step=i,this.min=a,this.max=l}return t.prototype.filter=function(t){return t<this.min||t>this.max||(this.tmp.push(t),this.old=this.calc(t)),this.old},t.prototype.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)},t.prototype.getMostNumberOfTmp=function(){var t,n,e,r={},o=0;try{for(var i=function(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.tmp),u=i.next();!u.done;u=i.next()){var a=u.value;r[a]?r[a]+=1:r[a]=1,r[a]>o&&(o=r[a],e=a)}}catch(n){t={error:n}}finally{try{u&&!u.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return{res:e,dic:r}},t}(),tt=function(){function t(t){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}(),nt=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:()=>_,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){return setTimeout((function(){n(),n=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=P((function(){return j(t,(function(e){e&&(o(),o=null,t=null,n(e),n=null)}))}),r||100);i&&setTimeout((function(){o(),o=null,t=null,e("timeout"),e=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 A(){}function T(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(A):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}}])&&T(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 k(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 _=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}}])&&k(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=t.limit,e=void 0===n?10:n,r=t.onTimeout;this.limit=10,this.onTimeout=void 0,this.timeout=null,this.limit=e,this.onTimeout=r}var n=t.prototype;return n.feed=function(){this.init()},n.init=function(){var t=this;clearTimeout(this.timeout),delete this.timeout,this.timeout=setTimeout((function(){return t.onTimeout()}),1e3*this.limit)},n.stop=function(){this.timeout&&clearTimeout(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})()));
package/es/color/utils.js CHANGED
@@ -1,3 +1,7 @@
1
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
2
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
5
  var str2int = function str2int(str) {
2
6
  return parseInt(str.replace('#', ''), 16);
3
7
  };
@@ -19,8 +23,9 @@ export var rgb2hex = function rgb2hex(color) {
19
23
  return color[i].toString(16);
20
24
  }).join('');
21
25
  };
22
- var ColorUtils = /** @class */function () {
26
+ export var ColorUtils = /*#__PURE__*/function () {
23
27
  function ColorUtils(n) {
28
+ this["int"] = void 0;
24
29
  if (typeof n === 'number') {
25
30
  this["int"] = n;
26
31
  } else if (typeof n === 'string') {
@@ -29,24 +34,11 @@ var ColorUtils = /** @class */function () {
29
34
  this["int"] = str2int(rgb2hex(n));
30
35
  }
31
36
  }
32
- ColorUtils.prototype.getRgbArray = function () {
37
+ var _proto = ColorUtils.prototype;
38
+ _proto.getRgbArray = function getRgbArray() {
33
39
  return hex2rgb(this["int"]);
34
40
  };
35
- Object.defineProperty(ColorUtils.prototype, "rgb", {
36
- get: function get() {
37
- return "rba(".concat(this.getRgbArray().join(', '), ")");
38
- },
39
- enumerable: false,
40
- configurable: true
41
- });
42
- Object.defineProperty(ColorUtils.prototype, "hex", {
43
- get: function get() {
44
- return rgb2hex(this.getRgbArray());
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- ColorUtils.prototype.toString = function (type) {
41
+ _proto.toString = function toString(type) {
50
42
  if (type === void 0) {
51
43
  type = 'hex';
52
44
  }
@@ -55,6 +47,16 @@ var ColorUtils = /** @class */function () {
55
47
  }
56
48
  return this.hex;
57
49
  };
50
+ _createClass(ColorUtils, [{
51
+ key: "rgb",
52
+ get: function get() {
53
+ return "rba(" + this.getRgbArray().join(', ') + ")";
54
+ }
55
+ }, {
56
+ key: "hex",
57
+ get: function get() {
58
+ return rgb2hex(this.getRgbArray());
59
+ }
60
+ }]);
58
61
  return ColorUtils;
59
- }();
60
- export { ColorUtils };
62
+ }();
@@ -1,69 +1,33 @@
1
- var __read = this && this.__read || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o),
5
- r,
6
- ar = [],
7
- e;
8
- try {
9
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
10
- } catch (error) {
11
- e = {
12
- error: error
13
- };
14
- } finally {
15
- try {
16
- if (r && !r.done && (m = i["return"])) m.call(i);
17
- } finally {
18
- if (e) throw e.error;
19
- }
20
- }
21
- return ar;
22
- };
23
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
24
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
- if (ar || !(i in from)) {
26
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
- ar[i] = from[i];
28
- }
29
- }
30
- return to.concat(ar || Array.prototype.slice.call(from));
31
- };
32
1
  export var debounce = function debounce(cb, time, first) {
33
2
  if (first === void 0) {
34
3
  first = false;
35
4
  }
36
5
  if (first) {
37
- var shouldRun_1 = true;
38
- var t_1;
6
+ var shouldRun = true;
7
+ var t;
39
8
  return function () {
40
- var args = [];
41
- for (var _i = 0; _i < arguments.length; _i++) {
42
- args[_i] = arguments[_i];
43
- }
44
- if (shouldRun_1) {
45
- cb.apply(void 0, __spreadArray([], __read(args), false));
46
- shouldRun_1 = false;
9
+ if (shouldRun) {
10
+ cb.apply(void 0, arguments);
11
+ shouldRun = false;
47
12
  }
48
- if (t_1) {
49
- clearTimeout(t_1);
13
+ if (t) {
14
+ clearTimeout(t);
50
15
  }
51
- t_1 = setTimeout(function () {
52
- return shouldRun_1 = true;
16
+ t = setTimeout(function () {
17
+ return shouldRun = true;
53
18
  }, time);
54
19
  };
55
20
  } else {
56
- var t_2;
21
+ var _t;
57
22
  return function () {
58
- var args = [];
59
- for (var _i = 0; _i < arguments.length; _i++) {
60
- args[_i] = arguments[_i];
23
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
+ args[_key] = arguments[_key];
61
25
  }
62
- if (t_2) {
63
- clearTimeout(t_2);
26
+ if (_t) {
27
+ clearTimeout(_t);
64
28
  }
65
- t_2 = setTimeout(function () {
66
- return cb.apply(void 0, __spreadArray([], __read(args), false));
29
+ _t = setTimeout(function () {
30
+ return cb.apply(void 0, args);
67
31
  }, time);
68
32
  };
69
33
  }