pubo-utils 1.0.32 → 1.0.33
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.
- package/dist/pubo-utils.js +1 -1
- package/es/debounce/index.d.ts +1 -1
- package/es/debounce/index.js +4 -0
- package/es/index.d.ts +0 -2
- package/es/index.js +1 -3
- package/es/loop/index.d.ts +6 -1
- package/es/loop/index.js +16 -5
- package/es/random/index.js +1 -1
- package/es/throttle/index.d.ts +1 -1
- package/lib/debounce/index.d.ts +1 -1
- package/lib/debounce/index.js +4 -0
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -18
- package/lib/loop/index.d.ts +6 -1
- package/lib/loop/index.js +16 -5
- package/lib/random/index.js +1 -1
- package/lib/throttle/index.d.ts +1 -1
- package/package.json +2 -2
- package/es/cache.d.ts +0 -6
- package/es/cache.js +0 -19
- package/es/watch-dog/index.d.ts +0 -14
- package/es/watch-dog/index.js +0 -49
- package/lib/cache.d.ts +0 -6
- package/lib/cache.js +0 -26
- package/lib/watch-dog/index.d.ts +0 -14
- package/lib/watch-dog/index.js +0 -56
package/dist/pubo-utils.js
CHANGED
|
@@ -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,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=0)}([function(t,n,e){"use strict";e.r(n),e.d(n,"debounce",(function(){return u})),e.d(n,"hex2rgb",(function(){return c})),e.d(n,"Emitter",(function(){return y})),e.d(n,"superFactory",(function(){return v})),e.d(n,"loop",(function(){return S})),e.d(n,"waitFor",(function(){return k})),e.d(n,"SyncQueue",(function(){return _})),e.d(n,"random",(function(){return a})),e.d(n,"sleep",(function(){return w})),e.d(n,"throttle",(function(){return E})),e.d(n,"ContinuousTrigger",(function(){return A})),e.d(n,"WatchDog",(function(){return M})),e.d(n,"Base64Utils",(function(){return r})),e.d(n,"HistoryStack",(function(){return C})),e.d(n,"Cache",(function(){return F}));var r={};e.r(r),e.d(r,"EncoderMap",(function(){return I})),e.d(r,"toUnit8Array",(function(){return G}));var 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(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(o(arguments[n]));return t},u=function(t,n,e){if(e){var r,o=!0;return function(){for(var e=[],u=0;u<arguments.length;u++)e[u]=arguments[u];o&&(t.apply(void 0,i(e)),o=!1),r&&clearTimeout(r),r=setTimeout((function(){return o=!0}),n)}}var u;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];u&&clearTimeout(u),u=setTimeout((function(){return t.apply(void 0,i(e))}),n)}},c=function(t){var n=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){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=8;r<=t;r+=8)e+=n(t-r>8?8:t-r);return e},l=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())}))},f=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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},s=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.")},h=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(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(h(arguments[n]));return t},y=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=a(40);return this.ids[r]={event:t,index:e},r},t.prototype.cancel=function(t){if(t){var n=this.ids[t]||{},e=n.event,r=n.index;e&&Array.isArray(this.state[e])&&this.state[e].splice(r,1)}else this.clear()},t.prototype.clear=function(){this.state.length=0},t.prototype.emit=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return l(this,void 0,void 0,(function(){var e,r,o,i,u,c;return f(this,(function(a){switch(a.label){case 0:if(!Array.isArray(this.state[t]))return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),e=s(this.state[t]),r=e.next(),a.label=2;case 2:return r.done?[3,5]:"function"!=typeof(o=r.value)?[3,4]:[4,o.apply(void 0,p(n))];case 3:a.sent(),a.label=4;case 4:return r=e.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),u={error:i},[3,8];case 7:try{r&&!r.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}return[7];case 8:return[2]}}))}))},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.")},v=function(t){return function(n){var e,r,o={};try{for(var i=d(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,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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},w=function(t){return b(void 0,void 0,void 0,(function(){return m(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]}}))}))},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())}))},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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},S=function(t,n){var e=!0,r=function(){e=!1},o=function(){return g(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,w(n)];case 2:return i.sent(),e?o():o=null,[2]}}))}))};return o(),r},k=function(t,n){return new Promise((function(e){S((function(n){return g(void 0,void 0,void 0,(function(){var r;return x(this,(function(o){switch(o.label){case 0:return[4,t()];case 1:return(r=o.sent())&&(n(),e(r)),[2]}}))}))}),n||100)}))},T=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())}))},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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},_=function(){function t(){this.cache=[],this.running=!1}return t.prototype._run=function(t){var n=t.fn,e=t.promise;return T(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 T(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,"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}(),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},O=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(P(arguments[n]));return t};function E(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(o)))}}var A=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(){function t(t){var n=t.limit,e=void 0===n?1:n,r=t.onTimeout;this.count=0,this.i=null,this.limit=e,this.onTimeout=r}return t.prototype.onTimeout=function(){console.log("timeout!")},t.prototype.onTimer=function(){this.count>this.limit&&"function"==typeof this.onTimeout?(this.onTimeout(),this.count=0):this.count++},t.prototype.init=function(){var t=this;this.i=setInterval((function(){return t.onTimer()}),1e3)},t.prototype.feed=function(){this.count=0},t.prototype.stop=function(){this.i&&(clearInterval(this.i),this.count=0)},t}(),I=function(){for(var t={},n=0;n<64;n++)t["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n)]=n;return t}();function G(t,n){for(var e=0,r=0,o=0,i=0;i<t.length&&o<n.length;i+=1)if(r=(r<<6)+I[t.charAt(i)],(e+=6)>=8){var u=r>>>(e-=8);n[o++]=255&u,r-=u<<=e}}var C=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-2&&(this.point+=1),this.current},t.prototype.redo=function(){return this.point>1&&(this.point-=1),this.current},t}(),F=function(){function t(t){this._=t}return t.prototype.get=function(){return this._},t.prototype.set=function(t){this._=t},t}()}])}));
|
|
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,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=0)}([function(t,n,e){"use strict";e.r(n),e.d(n,"debounce",(function(){return u})),e.d(n,"hex2rgb",(function(){return c})),e.d(n,"Emitter",(function(){return y})),e.d(n,"superFactory",(function(){return v})),e.d(n,"loop",(function(){return k})),e.d(n,"waitFor",(function(){return S})),e.d(n,"SyncQueue",(function(){return P})),e.d(n,"random",(function(){return a})),e.d(n,"sleep",(function(){return w})),e.d(n,"throttle",(function(){return E})),e.d(n,"ContinuousTrigger",(function(){return A})),e.d(n,"Base64Utils",(function(){return r})),e.d(n,"HistoryStack",(function(){return I}));var r={};e.r(r),e.d(r,"EncoderMap",(function(){return M})),e.d(r,"toUnit8Array",(function(){return G}));var 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(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(o(arguments[n]));return t},u=function(t,n,e){if(void 0===e&&(e=!1),e){var r,o=!0;return function(){for(var e=[],u=0;u<arguments.length;u++)e[u]=arguments[u];o&&(t.apply(void 0,i(e)),o=!1),r&&clearTimeout(r),r=setTimeout((function(){return o=!0}),n)}}var u;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];u&&clearTimeout(u),u=setTimeout((function(){return t.apply(void 0,i(e))}),n)}},c=function(t){var n=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){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},l=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())}))},f=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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},s=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.")},h=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(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(h(arguments[n]));return t},y=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=a(40);return this.ids[r]={event:t,index:e},r},t.prototype.cancel=function(t){if(t){var n=this.ids[t]||{},e=n.event,r=n.index;e&&Array.isArray(this.state[e])&&this.state[e].splice(r,1)}else this.clear()},t.prototype.clear=function(){this.state.length=0},t.prototype.emit=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return l(this,void 0,void 0,(function(){var e,r,o,i,u,c;return f(this,(function(a){switch(a.label){case 0:if(!Array.isArray(this.state[t]))return[3,8];a.label=1;case 1:a.trys.push([1,6,7,8]),e=s(this.state[t]),r=e.next(),a.label=2;case 2:return r.done?[3,5]:"function"!=typeof(o=r.value)?[3,4]:[4,o.apply(void 0,p(n))];case 3:a.sent(),a.label=4;case 4:return r=e.next(),[3,2];case 5:return[3,8];case 6:return i=a.sent(),u={error:i},[3,8];case 7:try{r&&!r.done&&(c=e.return)&&c.call(e)}finally{if(u)throw u.error}return[7];case 8:return[2]}}))}))},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.")},v=function(t){return function(n){var e,r,o={};try{for(var i=d(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,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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},w=function(t){return b(void 0,void 0,void 0,(function(){return m(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]}}))}))},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())}))},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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},k=function(t,n){var e=!0,r=function(){e=!1},o=function(){return g(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,w(n)];case 2:return i.sent(),e?o():o=null,[2]}}))}))};return o(),r},S=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,o=e.timeout;return new Promise((function(n,e){var i=k((function(){return g(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)}))},T=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())}))},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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},P=function(){function t(){this.cache=[],this.running=!1}return t.prototype._run=function(t){var n=t.fn,e=t.promise;return T(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 T(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,"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}(),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},_=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(O(arguments[n]));return t};function E(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)))}}var A=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 G(t,n){for(var 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}}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-2&&(this.point+=1),this.current},t.prototype.redo=function(){return this.point>1&&(this.point-=1),this.current},t}()}])}));
|
package/es/debounce/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const debounce: (cb: any, time: number, first?: boolean
|
|
1
|
+
export declare const debounce: (cb: any, time: number, first?: boolean) => (...args: any[]) => void;
|
package/es/debounce/index.js
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -8,7 +8,5 @@ export { random } from './random';
|
|
|
8
8
|
export { sleep } from './sleep';
|
|
9
9
|
export { throttle } from './throttle';
|
|
10
10
|
export { ContinuousTrigger } from './trigger';
|
|
11
|
-
export { WatchDog } from './watch-dog';
|
|
12
11
|
export * as Base64Utils from './base64';
|
|
13
12
|
export { HistoryStack } from './stack';
|
|
14
|
-
export { Cache } from './cache';
|
package/es/index.js
CHANGED
|
@@ -8,8 +8,6 @@ export { random } from './random';
|
|
|
8
8
|
export { sleep } from './sleep';
|
|
9
9
|
export { throttle } from './throttle';
|
|
10
10
|
export { ContinuousTrigger } from './trigger';
|
|
11
|
-
export { WatchDog } from './watch-dog';
|
|
12
11
|
import * as _Base64Utils from './base64';
|
|
13
12
|
export { _Base64Utils as Base64Utils };
|
|
14
|
-
export { HistoryStack } from './stack';
|
|
15
|
-
export { Cache } from './cache';
|
|
13
|
+
export { HistoryStack } from './stack';
|
package/es/loop/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export declare const loop: (cb: (stop: () => void) => Promise<void>, time: number) => () => void;
|
|
2
|
-
|
|
2
|
+
declare type WaitForBool = () => boolean | Promise<boolean>;
|
|
3
|
+
export declare const waitFor: (bool: WaitForBool, { checkTime, timeout }?: {
|
|
4
|
+
checkTime?: number | undefined;
|
|
5
|
+
timeout?: number | undefined;
|
|
6
|
+
}) => Promise<unknown>;
|
|
7
|
+
export {};
|
package/es/loop/index.js
CHANGED
|
@@ -186,9 +186,13 @@ export var loop = function loop(cb, time) {
|
|
|
186
186
|
|
|
187
187
|
return stop;
|
|
188
188
|
};
|
|
189
|
-
export var waitFor = function waitFor(
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
export var waitFor = function waitFor(bool, _a) {
|
|
190
|
+
var _b = _a === void 0 ? {} : _a,
|
|
191
|
+
checkTime = _b.checkTime,
|
|
192
|
+
timeout = _b.timeout;
|
|
193
|
+
|
|
194
|
+
return new Promise(function (resolve, reject) {
|
|
195
|
+
var stop = loop(function () {
|
|
192
196
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
193
197
|
var res;
|
|
194
198
|
return __generator(this, function (_a) {
|
|
@@ -196,7 +200,7 @@ export var waitFor = function waitFor(cb, time) {
|
|
|
196
200
|
case 0:
|
|
197
201
|
return [4
|
|
198
202
|
/*yield*/
|
|
199
|
-
,
|
|
203
|
+
, bool()];
|
|
200
204
|
|
|
201
205
|
case 1:
|
|
202
206
|
res = _a.sent();
|
|
@@ -212,6 +216,13 @@ export var waitFor = function waitFor(cb, time) {
|
|
|
212
216
|
}
|
|
213
217
|
});
|
|
214
218
|
});
|
|
215
|
-
},
|
|
219
|
+
}, checkTime || 100);
|
|
220
|
+
|
|
221
|
+
if (timeout) {
|
|
222
|
+
setTimeout(function () {
|
|
223
|
+
stop();
|
|
224
|
+
reject('timeout');
|
|
225
|
+
}, timeout);
|
|
226
|
+
}
|
|
216
227
|
});
|
|
217
228
|
};
|
package/es/random/index.js
CHANGED
package/es/throttle/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function throttle(cb: any, time:
|
|
1
|
+
export declare function throttle(cb: any, time: number): (...args: any[]) => void;
|
package/lib/debounce/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const debounce: (cb: any, time: number, first?: boolean
|
|
1
|
+
export declare const debounce: (cb: any, time: number, first?: boolean) => (...args: any[]) => void;
|
package/lib/debounce/index.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -8,7 +8,5 @@ export { random } from './random';
|
|
|
8
8
|
export { sleep } from './sleep';
|
|
9
9
|
export { throttle } from './throttle';
|
|
10
10
|
export { ContinuousTrigger } from './trigger';
|
|
11
|
-
export { WatchDog } from './watch-dog';
|
|
12
11
|
export * as Base64Utils from './base64';
|
|
13
12
|
export { HistoryStack } from './stack';
|
|
14
|
-
export { Cache } from './cache';
|
package/lib/index.js
CHANGED
|
@@ -133,15 +133,6 @@ Object.defineProperty(exports, "ContinuousTrigger", {
|
|
|
133
133
|
return trigger_1.ContinuousTrigger;
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
-
|
|
137
|
-
var watch_dog_1 = require("./watch-dog");
|
|
138
|
-
|
|
139
|
-
Object.defineProperty(exports, "WatchDog", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
get: function get() {
|
|
142
|
-
return watch_dog_1.WatchDog;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
136
|
exports.Base64Utils = __importStar(require("./base64"));
|
|
146
137
|
|
|
147
138
|
var stack_1 = require("./stack");
|
|
@@ -151,13 +142,4 @@ Object.defineProperty(exports, "HistoryStack", {
|
|
|
151
142
|
get: function get() {
|
|
152
143
|
return stack_1.HistoryStack;
|
|
153
144
|
}
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
var cache_1 = require("./cache");
|
|
157
|
-
|
|
158
|
-
Object.defineProperty(exports, "Cache", {
|
|
159
|
-
enumerable: true,
|
|
160
|
-
get: function get() {
|
|
161
|
-
return cache_1.Cache;
|
|
162
|
-
}
|
|
163
145
|
});
|
package/lib/loop/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export declare const loop: (cb: (stop: () => void) => Promise<void>, time: number) => () => void;
|
|
2
|
-
|
|
2
|
+
declare type WaitForBool = () => boolean | Promise<boolean>;
|
|
3
|
+
export declare const waitFor: (bool: WaitForBool, { checkTime, timeout }?: {
|
|
4
|
+
checkTime?: number | undefined;
|
|
5
|
+
timeout?: number | undefined;
|
|
6
|
+
}) => Promise<unknown>;
|
|
7
|
+
export {};
|
package/lib/loop/index.js
CHANGED
|
@@ -195,9 +195,13 @@ exports.loop = function (cb, time) {
|
|
|
195
195
|
return stop;
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
exports.waitFor = function (
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
exports.waitFor = function (bool, _a) {
|
|
199
|
+
var _b = _a === void 0 ? {} : _a,
|
|
200
|
+
checkTime = _b.checkTime,
|
|
201
|
+
timeout = _b.timeout;
|
|
202
|
+
|
|
203
|
+
return new Promise(function (resolve, reject) {
|
|
204
|
+
var stop = exports.loop(function () {
|
|
201
205
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
202
206
|
var res;
|
|
203
207
|
return __generator(this, function (_a) {
|
|
@@ -205,7 +209,7 @@ exports.waitFor = function (cb, time) {
|
|
|
205
209
|
case 0:
|
|
206
210
|
return [4
|
|
207
211
|
/*yield*/
|
|
208
|
-
,
|
|
212
|
+
, bool()];
|
|
209
213
|
|
|
210
214
|
case 1:
|
|
211
215
|
res = _a.sent();
|
|
@@ -221,6 +225,13 @@ exports.waitFor = function (cb, time) {
|
|
|
221
225
|
}
|
|
222
226
|
});
|
|
223
227
|
});
|
|
224
|
-
},
|
|
228
|
+
}, checkTime || 100);
|
|
229
|
+
|
|
230
|
+
if (timeout) {
|
|
231
|
+
setTimeout(function () {
|
|
232
|
+
stop();
|
|
233
|
+
reject('timeout');
|
|
234
|
+
}, timeout);
|
|
235
|
+
}
|
|
225
236
|
});
|
|
226
237
|
};
|
package/lib/random/index.js
CHANGED
package/lib/throttle/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function throttle(cb: any, time:
|
|
1
|
+
export declare function throttle(cb: any, time: number): (...args: any[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
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": "
|
|
21
|
+
"gitHead": "c6ca5e15ecf69336c5614aac127c74186e7c25c9"
|
|
22
22
|
}
|
package/es/cache.d.ts
DELETED
package/es/cache.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var Cache =
|
|
2
|
-
/** @class */
|
|
3
|
-
function () {
|
|
4
|
-
function Cache(props) {
|
|
5
|
-
this._ = props;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
Cache.prototype.get = function () {
|
|
9
|
-
return this._;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
Cache.prototype.set = function (data) {
|
|
13
|
-
this._ = data;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return Cache;
|
|
17
|
-
}();
|
|
18
|
-
|
|
19
|
-
export { Cache };
|
package/es/watch-dog/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class WatchDog {
|
|
2
|
-
private count;
|
|
3
|
-
private readonly limit;
|
|
4
|
-
private i;
|
|
5
|
-
constructor({ limit, onTimeout }: {
|
|
6
|
-
limit: number;
|
|
7
|
-
onTimeout: () => void;
|
|
8
|
-
});
|
|
9
|
-
private onTimeout;
|
|
10
|
-
private onTimer;
|
|
11
|
-
init(): void;
|
|
12
|
-
feed(): void;
|
|
13
|
-
stop(): void;
|
|
14
|
-
}
|
package/es/watch-dog/index.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var WatchDog =
|
|
2
|
-
/** @class */
|
|
3
|
-
function () {
|
|
4
|
-
function WatchDog(_a) {
|
|
5
|
-
var _b = _a.limit,
|
|
6
|
-
limit = _b === void 0 ? 1 : _b,
|
|
7
|
-
onTimeout = _a.onTimeout;
|
|
8
|
-
this.count = 0;
|
|
9
|
-
this.i = null;
|
|
10
|
-
this.limit = limit;
|
|
11
|
-
this.onTimeout = onTimeout;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
WatchDog.prototype.onTimeout = function () {
|
|
15
|
-
console.log('timeout!');
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
WatchDog.prototype.onTimer = function () {
|
|
19
|
-
if (this.count > this.limit && typeof this.onTimeout === 'function') {
|
|
20
|
-
this.onTimeout();
|
|
21
|
-
this.count = 0;
|
|
22
|
-
} else {
|
|
23
|
-
this.count++;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
WatchDog.prototype.init = function () {
|
|
28
|
-
var _this = this;
|
|
29
|
-
|
|
30
|
-
this.i = setInterval(function () {
|
|
31
|
-
return _this.onTimer();
|
|
32
|
-
}, 1000);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
WatchDog.prototype.feed = function () {
|
|
36
|
-
this.count = 0;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
WatchDog.prototype.stop = function () {
|
|
40
|
-
if (this.i) {
|
|
41
|
-
clearInterval(this.i);
|
|
42
|
-
this.count = 0;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return WatchDog;
|
|
47
|
-
}();
|
|
48
|
-
|
|
49
|
-
export { WatchDog };
|
package/lib/cache.d.ts
DELETED
package/lib/cache.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Cache = void 0;
|
|
7
|
-
|
|
8
|
-
var Cache =
|
|
9
|
-
/** @class */
|
|
10
|
-
function () {
|
|
11
|
-
function Cache(props) {
|
|
12
|
-
this._ = props;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
Cache.prototype.get = function () {
|
|
16
|
-
return this._;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
Cache.prototype.set = function (data) {
|
|
20
|
-
this._ = data;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return Cache;
|
|
24
|
-
}();
|
|
25
|
-
|
|
26
|
-
exports.Cache = Cache;
|
package/lib/watch-dog/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class WatchDog {
|
|
2
|
-
private count;
|
|
3
|
-
private readonly limit;
|
|
4
|
-
private i;
|
|
5
|
-
constructor({ limit, onTimeout }: {
|
|
6
|
-
limit: number;
|
|
7
|
-
onTimeout: () => void;
|
|
8
|
-
});
|
|
9
|
-
private onTimeout;
|
|
10
|
-
private onTimer;
|
|
11
|
-
init(): void;
|
|
12
|
-
feed(): void;
|
|
13
|
-
stop(): void;
|
|
14
|
-
}
|
package/lib/watch-dog/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WatchDog = void 0;
|
|
7
|
-
|
|
8
|
-
var WatchDog =
|
|
9
|
-
/** @class */
|
|
10
|
-
function () {
|
|
11
|
-
function WatchDog(_a) {
|
|
12
|
-
var _b = _a.limit,
|
|
13
|
-
limit = _b === void 0 ? 1 : _b,
|
|
14
|
-
onTimeout = _a.onTimeout;
|
|
15
|
-
this.count = 0;
|
|
16
|
-
this.i = null;
|
|
17
|
-
this.limit = limit;
|
|
18
|
-
this.onTimeout = onTimeout;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
WatchDog.prototype.onTimeout = function () {
|
|
22
|
-
console.log('timeout!');
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
WatchDog.prototype.onTimer = function () {
|
|
26
|
-
if (this.count > this.limit && typeof this.onTimeout === 'function') {
|
|
27
|
-
this.onTimeout();
|
|
28
|
-
this.count = 0;
|
|
29
|
-
} else {
|
|
30
|
-
this.count++;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
WatchDog.prototype.init = function () {
|
|
35
|
-
var _this = this;
|
|
36
|
-
|
|
37
|
-
this.i = setInterval(function () {
|
|
38
|
-
return _this.onTimer();
|
|
39
|
-
}, 1000);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
WatchDog.prototype.feed = function () {
|
|
43
|
-
this.count = 0;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
WatchDog.prototype.stop = function () {
|
|
47
|
-
if (this.i) {
|
|
48
|
-
clearInterval(this.i);
|
|
49
|
-
this.count = 0;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return WatchDog;
|
|
54
|
-
}();
|
|
55
|
-
|
|
56
|
-
exports.WatchDog = WatchDog;
|