pubo-utils 1.0.43 → 1.0.47
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/index.d.ts +3 -0
- package/es/index.js +5 -1
- package/es/level/index.d.ts +11 -0
- package/es/level/index.js +23 -0
- package/es/math/geometry.d.ts +7 -0
- package/es/math/geometry.js +27 -0
- package/es/promise/index.d.ts +1 -0
- package/es/promise/index.js +65 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +19 -0
- package/lib/level/index.d.ts +11 -0
- package/lib/level/index.js +30 -0
- package/lib/math/geometry.d.ts +7 -0
- package/lib/math/geometry.js +37 -0
- package/lib/promise/index.d.ts +1 -0
- package/lib/promise/index.js +71 -0
- package/package.json +2 -2
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 h})),e.d(n,"superFactory",(function(){return y})),e.d(n,"loop",(function(){return w})),e.d(n,"waitFor",(function(){return x})),e.d(n,"SyncQueue",(function(){return T})),e.d(n,"random",(function(){return a})),e.d(n,"sleep",(function(){return b})),e.d(n,"throttle",(function(){return P})),e.d(n,"ContinuousTrigger",(function(){return _})),e.d(n,"Base64Utils",(function(){return r})),e.d(n,"HistoryStack",(function(){return M})),e.d(n,"WatchDog",(function(){return G}));var r={};e.r(r),e.d(r,"EncoderMap",(function(){return E})),e.d(r,"toUnit8Array",(function(){return A}));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},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.")},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},s=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(l(arguments[n]));return t},h=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){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,s(r))}}catch(t){n={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(n)throw n.error}}},t}(),p=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.")},y=function(t){return function(n){var e,r,o={};try{for(var i=p(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}},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())}))},v=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])}}},b=function(t){return d(void 0,void 0,void 0,(function(){return v(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]}}))}))},m=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())}))},g=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,n){var e=!0,r=function(){e=!1},o=function(){return m(void 0,void 0,void 0,(function(){return g(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 m(void 0,void 0,void 0,(function(){var e;return g(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(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])}}},T=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}(),j=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(j(arguments[n]));return t};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(o)))}}var _=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 A(t,n){for(var 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}}var M=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}(),G=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}()}])}));
|
|
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 c})),e.d(n,"hex2rgb",(function(){return a})),e.d(n,"Emitter",(function(){return p})),e.d(n,"superFactory",(function(){return d})),e.d(n,"loop",(function(){return x})),e.d(n,"waitFor",(function(){return S})),e.d(n,"SyncQueue",(function(){return j})),e.d(n,"random",(function(){return f})),e.d(n,"sleep",(function(){return m})),e.d(n,"throttle",(function(){return O})),e.d(n,"ContinuousTrigger",(function(){return _})),e.d(n,"Base64Utils",(function(){return r})),e.d(n,"HistoryStack",(function(){return I})),e.d(n,"WatchDog",(function(){return G})),e.d(n,"Level",(function(){return q})),e.d(n,"PuboGeometry",(function(){return o})),e.d(n,"callbackToPromise",(function(){return L}));var r={};e.r(r),e.d(r,"EncoderMap",(function(){return E})),e.d(r,"toUnit8Array",(function(){return A}));var o={};e.r(o),e.d(o,"getDistance",(function(){return D})),e.d(o,"degrees",(function(){return F})),e.d(o,"radians",(function(){return U})),e.d(o,"getAngle",(function(){return B}));var i=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},u=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(i(arguments[n]));return t},c=function(t,n,e){if(void 0===e&&(e=!1),e){var r,o=!0;return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];o&&(t.apply(void 0,u(e)),o=!1),r&&clearTimeout(r),r=setTimeout((function(){return o=!0}),n)}}var i;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];i&&clearTimeout(i),i=setTimeout((function(){return t.apply(void 0,u(e))}),n)}},a=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)]},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},l=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(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(s(arguments[n]));return t},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=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=l(this.state[t]),u=i.next();!u.done;u=i.next()){var c=u.value;"function"==typeof c&&c.apply(void 0,h(r))}}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){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(t){return function(n){var e,r,o={};try{for(var i=y(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,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(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])}}},m=function(t){return v(void 0,void 0,void 0,(function(){return b(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())}))},w=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])}}},x=function(t,n){var e=!0,r=function(){e=!1},o=function(){return g(void 0,void 0,void 0,(function(){return w(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},S=function(t,n){var e=void 0===n?{}:n,r=e.checkTime,o=e.timeout;return new Promise((function(n,e){var i=x((function(){return g(void 0,void 0,void 0,(function(){var e;return w(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{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())}))},T=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])}}},j=function(){function t(){this.cache=[],this.running=!1}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 T(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 T(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},M=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(P(arguments[n]));return t};function O(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,M(o)))}}var _=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 A(t,n){for(var 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}}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}(),G=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}(),q=function(){function t(t){this.config=t}return t.prototype.get=function(t){for(var n=(this.config.max-this.config.min)/(this.config.count-1),e=1,r=this.config.min+n;r<this.config.max+n;r+=n,e+=1)if(t<r)return e;return this.config.count},t}(),D=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},U=function(t){return t*Math.PI/180},B=function(t){var n=t.w,e=t.h,r=F(Math.asin(e/Math.sqrt(Math.pow(n,2)+Math.pow(e,2))));return n<=0?180-r:r>0?r:360+r},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},H=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(C(arguments[n]));return t},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,H(n,[function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];t&&r(t),n.length<2?e(n):e(H(n))}]))}))}}}])}));
|
package/es/index.d.ts
CHANGED
|
@@ -11,3 +11,6 @@ export { ContinuousTrigger } from './trigger';
|
|
|
11
11
|
export * as Base64Utils from './base64';
|
|
12
12
|
export { HistoryStack } from './stack';
|
|
13
13
|
export { WatchDog } from './watch-dog';
|
|
14
|
+
export { Level } from './level';
|
|
15
|
+
export * as PuboGeometry from './math/geometry';
|
|
16
|
+
export { callbackToPromise } from './promise';
|
package/es/index.js
CHANGED
|
@@ -11,4 +11,8 @@ export { ContinuousTrigger } from './trigger';
|
|
|
11
11
|
import * as _Base64Utils from './base64';
|
|
12
12
|
export { _Base64Utils as Base64Utils };
|
|
13
13
|
export { HistoryStack } from './stack';
|
|
14
|
-
export { WatchDog } from './watch-dog';
|
|
14
|
+
export { WatchDog } from './watch-dog';
|
|
15
|
+
export { Level } from './level';
|
|
16
|
+
import * as _PuboGeometry from './math/geometry';
|
|
17
|
+
export { _PuboGeometry as PuboGeometry };
|
|
18
|
+
export { callbackToPromise } from './promise';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var Level =
|
|
2
|
+
/** @class */
|
|
3
|
+
function () {
|
|
4
|
+
function Level(props) {
|
|
5
|
+
this.config = props;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
Level.prototype.get = function (value) {
|
|
9
|
+
var step = (this.config.max - this.config.min) / (this.config.count - 1);
|
|
10
|
+
|
|
11
|
+
for (var i = 1, v = this.config.min + step; v < this.config.max + step; v += step, i += 1) {
|
|
12
|
+
if (value < v) {
|
|
13
|
+
return i;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return this.config.count;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return Level;
|
|
21
|
+
}();
|
|
22
|
+
|
|
23
|
+
export { Level };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export var getDistance = function getDistance(a, b) {
|
|
2
|
+
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
|
|
3
|
+
}; // 弧度转角度
|
|
4
|
+
|
|
5
|
+
export var degrees = function degrees(rad) {
|
|
6
|
+
return rad * 180 / Math.PI;
|
|
7
|
+
}; // 角度转弧度
|
|
8
|
+
|
|
9
|
+
export var radians = function radians(deg) {
|
|
10
|
+
return deg * Math.PI / 180;
|
|
11
|
+
}; // 获取角度
|
|
12
|
+
|
|
13
|
+
export var getAngle = function getAngle(_a) {
|
|
14
|
+
var w = _a.w,
|
|
15
|
+
h = _a.h;
|
|
16
|
+
var a = degrees(Math.asin(h / Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2))));
|
|
17
|
+
|
|
18
|
+
if (w <= 0) {
|
|
19
|
+
return 180 - a;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (a > 0) {
|
|
23
|
+
return a;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return 360 + a;
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const callbackToPromise: (fn: any) => any;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
|
|
9
|
+
try {
|
|
10
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
11
|
+
ar.push(r.value);
|
|
12
|
+
}
|
|
13
|
+
} catch (error) {
|
|
14
|
+
e = {
|
|
15
|
+
error: error
|
|
16
|
+
};
|
|
17
|
+
} finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
} finally {
|
|
21
|
+
if (e) throw e.error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var __spread = this && this.__spread || function () {
|
|
29
|
+
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
30
|
+
ar = ar.concat(__read(arguments[i]));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return ar;
|
|
34
|
+
}; // 回调函数转异步函数
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export var callbackToPromise = function callbackToPromise(fn) {
|
|
38
|
+
return function () {
|
|
39
|
+
var args = [];
|
|
40
|
+
|
|
41
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
42
|
+
args[_i] = arguments[_i];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return new Promise(function (resolve, reject) {
|
|
46
|
+
fn.apply(void 0, __spread(args, [function (err) {
|
|
47
|
+
var rest = [];
|
|
48
|
+
|
|
49
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
50
|
+
rest[_i - 1] = arguments[_i];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (err) {
|
|
54
|
+
reject(err);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (rest.length < 2) {
|
|
58
|
+
resolve(rest);
|
|
59
|
+
} else {
|
|
60
|
+
resolve(__spread(rest));
|
|
61
|
+
}
|
|
62
|
+
}]));
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -11,3 +11,6 @@ export { ContinuousTrigger } from './trigger';
|
|
|
11
11
|
export * as Base64Utils from './base64';
|
|
12
12
|
export { HistoryStack } from './stack';
|
|
13
13
|
export { WatchDog } from './watch-dog';
|
|
14
|
+
export { Level } from './level';
|
|
15
|
+
export * as PuboGeometry from './math/geometry';
|
|
16
|
+
export { callbackToPromise } from './promise';
|
package/lib/index.js
CHANGED
|
@@ -151,4 +151,23 @@ Object.defineProperty(exports, "WatchDog", {
|
|
|
151
151
|
get: function get() {
|
|
152
152
|
return watch_dog_1.WatchDog;
|
|
153
153
|
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
var level_1 = require("./level");
|
|
157
|
+
|
|
158
|
+
Object.defineProperty(exports, "Level", {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function get() {
|
|
161
|
+
return level_1.Level;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
exports.PuboGeometry = __importStar(require("./math/geometry"));
|
|
165
|
+
|
|
166
|
+
var promise_1 = require("./promise");
|
|
167
|
+
|
|
168
|
+
Object.defineProperty(exports, "callbackToPromise", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function get() {
|
|
171
|
+
return promise_1.callbackToPromise;
|
|
172
|
+
}
|
|
154
173
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Level = void 0;
|
|
7
|
+
|
|
8
|
+
var Level =
|
|
9
|
+
/** @class */
|
|
10
|
+
function () {
|
|
11
|
+
function Level(props) {
|
|
12
|
+
this.config = props;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Level.prototype.get = function (value) {
|
|
16
|
+
var step = (this.config.max - this.config.min) / (this.config.count - 1);
|
|
17
|
+
|
|
18
|
+
for (var i = 1, v = this.config.min + step; v < this.config.max + step; v += step, i += 1) {
|
|
19
|
+
if (value < v) {
|
|
20
|
+
return i;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return this.config.count;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return Level;
|
|
28
|
+
}();
|
|
29
|
+
|
|
30
|
+
exports.Level = Level;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAngle = exports.radians = exports.degrees = exports.getDistance = void 0;
|
|
7
|
+
|
|
8
|
+
exports.getDistance = function (a, b) {
|
|
9
|
+
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
|
|
10
|
+
}; // 弧度转角度
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.degrees = function (rad) {
|
|
14
|
+
return rad * 180 / Math.PI;
|
|
15
|
+
}; // 角度转弧度
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.radians = function (deg) {
|
|
19
|
+
return deg * Math.PI / 180;
|
|
20
|
+
}; // 获取角度
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
exports.getAngle = function (_a) {
|
|
24
|
+
var w = _a.w,
|
|
25
|
+
h = _a.h;
|
|
26
|
+
var a = exports.degrees(Math.asin(h / Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2))));
|
|
27
|
+
|
|
28
|
+
if (w <= 0) {
|
|
29
|
+
return 180 - a;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (a > 0) {
|
|
33
|
+
return a;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return 360 + a;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const callbackToPromise: (fn: any) => any;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
|
|
11
|
+
try {
|
|
12
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
13
|
+
ar.push(r.value);
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
e = {
|
|
17
|
+
error: error
|
|
18
|
+
};
|
|
19
|
+
} finally {
|
|
20
|
+
try {
|
|
21
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
22
|
+
} finally {
|
|
23
|
+
if (e) throw e.error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var __spread = this && this.__spread || function () {
|
|
31
|
+
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
32
|
+
ar = ar.concat(__read(arguments[i]));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
Object.defineProperty(exports, "__esModule", {
|
|
39
|
+
value: true
|
|
40
|
+
});
|
|
41
|
+
exports.callbackToPromise = void 0; // 回调函数转异步函数
|
|
42
|
+
|
|
43
|
+
exports.callbackToPromise = function (fn) {
|
|
44
|
+
return function () {
|
|
45
|
+
var args = [];
|
|
46
|
+
|
|
47
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
48
|
+
args[_i] = arguments[_i];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return new Promise(function (resolve, reject) {
|
|
52
|
+
fn.apply(void 0, __spread(args, [function (err) {
|
|
53
|
+
var rest = [];
|
|
54
|
+
|
|
55
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
56
|
+
rest[_i - 1] = arguments[_i];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (err) {
|
|
60
|
+
reject(err);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (rest.length < 2) {
|
|
64
|
+
resolve(rest);
|
|
65
|
+
} else {
|
|
66
|
+
resolve(__spread(rest));
|
|
67
|
+
}
|
|
68
|
+
}]));
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
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": "9eea3d7ccae6ce8daa0232f2de24938095d15d4b"
|
|
22
22
|
}
|