pubo-utils 1.0.69 → 1.0.78

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:()=>P,Emitter:()=>p,HistoryStack:()=>O,Level:()=>_,RegExpList:()=>B,SyncQueue:()=>S,WatchDog:()=>M,callbackToPromise:()=>L,concatArray:()=>H,debounce:()=>i,degrees:()=>q,filterKeyPoints:()=>F,getAngle:()=>D,getCenter:()=>X,getDistance:()=>U,hex2rgb:()=>c,loop:()=>g,radians:()=>C,random:()=>l,sleep:()=>v,superFactory:()=>y,throttle:()=>A,waitFor:()=>m});var e={};t.r(e),t.d(e,{EncoderMap:()=>j,toUnit8Array:()=>E});var r=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))},i=function(t,n,e){if(void 0===e&&(e=!1),e){var i,u=!0;return function(){for(var e=[],c=0;c<arguments.length;c++)e[c]=arguments[c];u&&(t.apply(void 0,o([],r(e),!1)),u=!1),i&&clearTimeout(i),i=setTimeout((function(){return u=!0}),n)}}var c;return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];c&&clearTimeout(c),c=setTimeout((function(){return t.apply(void 0,o([],r(e),!1))}),n)}},u=function(t){return parseInt(t.replace("#",""),16)},c=function(t){var n=("string"==typeof t?u(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)]},a=function(t){return"#"+[0,1,2].map((function(n){return t[n].toString(16)})).join("")},l=(function(){function t(t){"number"==typeof t?this.int=t:"string"==typeof t?this.int=u(t):Array.isArray(t)&&(this.int=u(a(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 a(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){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}),f=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.")},s=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},h=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))},p=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=l(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){for(var n,e,r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(Array.isArray(this.state[t]))try{for(var i=f(this.state[t]),u=i.next();!u.done;u=i.next()){var c=u.value;"function"==typeof c&&c.apply(void 0,h([],s(r),!1))}}catch(t){n={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(n)throw n.error}}},t}(),y=function(t){return function(n){var e,r,o={};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.")}(Object.keys(n)),u=i.next();!u.done;u=i.next()){var c=u.value;o[c]=t(n[c],c)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return o}},v=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}(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{a(o.next(t))}catch(t){i(t)}}function c(t){try{a(o.throw(t))}catch(t){i(t)}}function a(n){var e;n.done?t(n.value):(e=n.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,c)}a((o=o.apply(n,e||[])).next())}));var n,e,r,o},d=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))},b=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},g=function(t,n){var e=!0,r=function(){e=!1},o=function(){return d(void 0,void 0,void 0,(function(){return b(this,(function(i){switch(i.label){case 0:return[4,t(r)];case 1:return i.sent(),[4,v(n)];case 2:return i.sent(),e?o():o=null,[2]}}))}))};return o(),r},m=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,o=e.timeout;return new Promise((function(n,e){var i=g((function(){return d(void 0,void 0,void 0,(function(){var e;return b(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)}))},w=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},S=function(){function t(){this.cache=[],this.running=!1}return t.prototype._run=function(t){var n=t.fn,e=t.promise;return w(this,void 0,void 0,(function(){var t,r;return x(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 w(this,void 0,void 0,(function(){var t;return x(this,(function(n){switch(n.label){case 0:return this.cache.length<1?(this.running=!1,[2]):(this.running=!0,"function"!=typeof(t=this.cache.shift()).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 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.cache.length},enumerable:!1,configurable:!0}),t}(),k=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=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 A(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,T([],k(o),!1)))}}var P=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}(),j=function(){for(var t={},n=0;n<64;n++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n)]=n;return t}();function E(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)+j[t.charAt(i)],(e+=6)>=8){var u=r>>>(e-=8);n[o++]=255&u,r-=u<<=e}return n}var O=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}(),M=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(){clearTimeout(this.timeout),this.init()},t.prototype.init=function(){var t=this;this.timeout=setTimeout((function(){return t.onTimeout()}),1e3*this.limit)},t.prototype.stop=function(){this.timeout&&clearTimeout(this.timeout)},t}(),_=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}(),R=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))},L=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,I(I([],R(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(I([],R(n),!1))}],!1))}))}},G=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.")},U=function(t,n){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))},q=function(t){return 180*t/Math.PI},C=function(t){return t*Math.PI/180},D=function(t){var n,e=t.w,r=t.h,o=q(Math.asin(r/Math.sqrt(Math.pow(e,2)+Math.pow(r,2))));return(n=e<=0?180-o:o>0?o:360+o)<-180&&(n+=360),n>180&&(n-=360),n};function F(t,n){return void 0===n&&(n=.5),t.length<3||n<=0?t:t.filter((function(r,o){return!(o>0&&U(e,r)<n||(e=t[o],0))}));var e}function X(t){var n,e,r=[0,0];try{for(var o=G(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}}var B=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,"g")},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}(),H=function(t,n){void 0===n&&(n=Array);for(var e=t.map((function(t){return t.length})).reduce((function(t,n){return t+n}),0),r=new n(e),o=0,i=0,u=0;u<e;)o<t[i].length?(r[u]=t[i][o],o+=1,u+=1):(i+=1,o=0);return r};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:()=>E,Emitter:()=>v,HistoryStack:()=>_,Level:()=>I,RegExpList:()=>K,SyncQueue:()=>A,WatchDog:()=>R,callbackToPromise:()=>U,concatArray:()=>N,debounce:()=>i,degrees:()=>D,filterKeyPoints:()=>B,getAngle:()=>X,getCenter:()=>H,getDistance:()=>C,hex2rgb:()=>c,loop:()=>w,radians:()=>F,random:()=>f,randomRangeNum:()=>s,sleep:()=>b,superFactory:()=>d,throttle:()=>j,waitFor:()=>x});var e={};t.r(e),t.d(e,{EncoderMap:()=>M,toUnit8Array:()=>O});var r=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))},i=function(t,n,e){if(void 0===e&&(e=!1),e){var i,u=!0;return function(){for(var e=[],c=0;c<arguments.length;c++)e[c]=arguments[c];u&&(t.apply(void 0,o([],r(e),!1)),u=!1),i&&clearTimeout(i),i=setTimeout((function(){return u=!0}),n)}}var c;return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];c&&clearTimeout(c),c=setTimeout((function(){return t.apply(void 0,o([],r(e),!1))}),n)}},u=function(t){return parseInt(t.replace("#",""),16)},c=function(t){var n=("string"==typeof t?u(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)]},a=function(t){return"#"+[0,1,2].map((function(n){return t[n].toString(16)})).join("")},l=(function(){function t(t){"number"==typeof t?this.int=t:"string"==typeof t?this.int=u(t):Array.isArray(t)&&(this.int=u(a(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 a(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},s=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))}([],l(t),!1))},h=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.")},p=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},y=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))},v=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){for(var n,e,r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(Array.isArray(this.state[t]))try{for(var i=h(this.state[t]),u=i.next();!u.done;u=i.next()){var c=u.value;"function"==typeof c&&c.apply(void 0,y([],p(r),!1))}}catch(t){n={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(n)throw n.error}}},t}(),d=function(t){return function(n){var e,r,o={};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.")}(Object.keys(n)),u=i.next();!u.done;u=i.next()){var c=u.value;o[c]=t(n[c],c)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return o}},b=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}(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{a(o.next(t))}catch(t){i(t)}}function c(t){try{a(o.throw(t))}catch(t){i(t)}}function a(n){var e;n.done?t(n.value):(e=n.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,c)}a((o=o.apply(n,e||[])).next())}));var n,e,r,o},g=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))},m=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},w=function(t,n){var e=!0,r=function(){e=!1},o=function(){return g(void 0,void 0,void 0,(function(){return m(this,(function(i){switch(i.label){case 0:return[4,t(r)];case 1:return i.sent(),[4,b(n)];case 2:return i.sent(),e?o():o=null,[2]}}))}))};return o(),r},x=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,o=e.timeout;return new Promise((function(n,e){var i=w((function(){return g(void 0,void 0,void 0,(function(){var e;return m(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)}))},S=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))},k=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},A=function(){function t(){this.cache=[],this.running=!1}return t.prototype._run=function(t){var n=t.fn,e=t.promise;return S(this,void 0,void 0,(function(){var t,r;return k(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 S(this,void 0,void 0,(function(){var t;return k(this,(function(n){switch(n.label){case 0:return this.cache.length<1?(this.running=!1,[2]):(this.running=!0,"function"!=typeof(t=this.cache.shift()).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 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.cache.length},enumerable:!1,configurable:!0}),t}(),T=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},P=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 j(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,P([],T(o),!1)))}}var E=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}(),M=function(){for(var t={},n=0;n<64;n++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n)]=n;return t}();function O(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)+M[t.charAt(i)],(e+=6)>=8){var u=r>>>(e-=8);n[o++]=255&u,r-=u<<=e}return n}var _=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}(),R=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(){clearTimeout(this.timeout),this.init()},t.prototype.init=function(){var t=this;this.timeout=setTimeout((function(){return t.onTimeout()}),1e3*this.limit)},t.prototype.stop=function(){this.timeout&&clearTimeout(this.timeout)},t}(),I=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}(),L=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},G=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){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,G(G([],L(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(G([],L(n),!1))}],!1))}))}},q=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.")},C=function(t,n){return Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2))},D=function(t){return 180*t/Math.PI},F=function(t){return t*Math.PI/180},X=function(t){var n,e=t.w,r=t.h,o=D(Math.asin(r/Math.sqrt(Math.pow(e,2)+Math.pow(r,2))));return(n=e<=0?180-o:o>0?o:360+o)<-180&&(n+=360),n>180&&(n-=360),n};function B(t,n){return void 0===n&&(n=.5),t.length<3||n<=0?t:t.filter((function(r,o){return!(o>0&&C(e,r)<n||(e=t[o],0))}));var e}function H(t){var n,e,r=[0,0];try{for(var o=q(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}}var K=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,"g")},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}(),N=function(t,n){void 0===n&&(n=Array);for(var e=t.map((function(t){return t.length})).reduce((function(t,n){return t+n}),0),r=new n(e),o=0,i=0,u=0;u<e;)o<t[i].length?(r[u]=t[i][o],o+=1,u+=1):(i+=1,o=0);return r};return n})()));
package/es/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { Emitter } from './emitter';
4
4
  export { superFactory } from './factory';
5
5
  export { loop, waitFor } from './loop';
6
6
  export { SyncQueue } from './queue';
7
- export { random } from './random';
7
+ export { random, randomRangeNum } from './random';
8
8
  export { sleep } from './sleep';
9
9
  export { throttle } from './throttle';
10
10
  export { ContinuousTrigger } from './trigger';
package/es/index.js CHANGED
@@ -4,7 +4,7 @@ export { Emitter } from './emitter';
4
4
  export { superFactory } from './factory';
5
5
  export { loop, waitFor } from './loop';
6
6
  export { SyncQueue } from './queue';
7
- export { random } from './random';
7
+ export { random, randomRangeNum } from './random';
8
8
  export { sleep } from './sleep';
9
9
  export { throttle } from './throttle';
10
10
  export { ContinuousTrigger } from './trigger';
@@ -1 +1,2 @@
1
1
  export declare const random: (n?: number) => string;
2
+ export declare const randomRangeNum: (range: any) => number;
@@ -1,3 +1,34 @@
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
+ };
1
32
  export var random = function random(n) {
2
33
  if (n === void 0) {
3
34
  n = 8;
@@ -17,4 +48,8 @@ export var random = function random(n) {
17
48
  }
18
49
  }
19
50
  return res;
51
+ };
52
+ export var randomRangeNum = function randomRangeNum(range) {
53
+ var size = Math.abs(range[1] - range[0]);
54
+ return Math.random() * size + Math.min.apply(Math, __spreadArray([], __read(range), false));
20
55
  };
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { Emitter } from './emitter';
4
4
  export { superFactory } from './factory';
5
5
  export { loop, waitFor } from './loop';
6
6
  export { SyncQueue } from './queue';
7
- export { random } from './random';
7
+ export { random, randomRangeNum } from './random';
8
8
  export { sleep } from './sleep';
9
9
  export { throttle } from './throttle';
10
10
  export { ContinuousTrigger } from './trigger';
package/lib/index.js CHANGED
@@ -34,7 +34,7 @@ var __importStar = this && this.__importStar || function (mod) {
34
34
  Object.defineProperty(exports, "__esModule", {
35
35
  value: true
36
36
  });
37
- exports.concatArray = exports.RegExpList = exports.filterKeyPoints = exports.radians = exports.degrees = exports.getCenter = exports.getDistance = exports.getAngle = exports.callbackToPromise = exports.Level = exports.WatchDog = exports.HistoryStack = exports.Base64Utils = exports.ContinuousTrigger = exports.throttle = exports.sleep = exports.random = exports.SyncQueue = exports.waitFor = exports.loop = exports.superFactory = exports.Emitter = exports.hex2rgb = exports.debounce = void 0;
37
+ exports.concatArray = exports.RegExpList = exports.filterKeyPoints = exports.radians = exports.degrees = exports.getCenter = exports.getDistance = exports.getAngle = exports.callbackToPromise = exports.Level = exports.WatchDog = exports.HistoryStack = exports.Base64Utils = exports.ContinuousTrigger = exports.throttle = exports.sleep = exports.randomRangeNum = exports.random = exports.SyncQueue = exports.waitFor = exports.loop = exports.superFactory = exports.Emitter = exports.hex2rgb = exports.debounce = void 0;
38
38
  var debounce_1 = require("./debounce");
39
39
  Object.defineProperty(exports, "debounce", {
40
40
  enumerable: true,
@@ -90,6 +90,12 @@ Object.defineProperty(exports, "random", {
90
90
  return random_1.random;
91
91
  }
92
92
  });
93
+ Object.defineProperty(exports, "randomRangeNum", {
94
+ enumerable: true,
95
+ get: function get() {
96
+ return random_1.randomRangeNum;
97
+ }
98
+ });
93
99
  var sleep_1 = require("./sleep");
94
100
  Object.defineProperty(exports, "sleep", {
95
101
  enumerable: true,
@@ -1 +1,2 @@
1
1
  export declare const random: (n?: number) => string;
2
+ export declare const randomRangeNum: (range: any) => number;
@@ -1,9 +1,40 @@
1
1
  "use strict";
2
2
 
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
21
+ }
22
+ }
23
+ return ar;
24
+ };
25
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
26
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
+ if (ar || !(i in from)) {
28
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
29
+ ar[i] = from[i];
30
+ }
31
+ }
32
+ return to.concat(ar || Array.prototype.slice.call(from));
33
+ };
3
34
  Object.defineProperty(exports, "__esModule", {
4
35
  value: true
5
36
  });
6
- exports.random = void 0;
37
+ exports.randomRangeNum = exports.random = void 0;
7
38
  var random = function random(n) {
8
39
  if (n === void 0) {
9
40
  n = 8;
@@ -24,4 +55,9 @@ var random = function random(n) {
24
55
  }
25
56
  return res;
26
57
  };
27
- exports.random = random;
58
+ exports.random = random;
59
+ var randomRangeNum = function randomRangeNum(range) {
60
+ var size = Math.abs(range[1] - range[0]);
61
+ return Math.random() * size + Math.min.apply(Math, __spreadArray([], __read(range), false));
62
+ };
63
+ exports.randomRangeNum = randomRangeNum;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-utils",
3
- "version": "1.0.69",
3
+ "version": "1.0.78",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,5 +18,5 @@
18
18
  "engines": {
19
19
  "node": ">=8.0.0"
20
20
  },
21
- "gitHead": "1d63c277c36fc7e451e0a685e9d29f9082efc483"
21
+ "gitHead": "fcecf50aa7224cbb792821a0cc951c0aa6626444"
22
22
  }