qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/CodeTool.js

2 lines
1.3 KiB
JavaScript

define((function(){"use strict";return class{constructor(){}static getHeaderArray(t){let r=[];for(let n=0;n<t;n++)r[n]=this._getRandomNum();return r}static _getRandomNum(){let t=Math.random();return 50+Math.round(80*t)}static stringToByte(t,r){void 0===r&&(r="utf8");let n=[],e=Buffer.from(t,r);for(let t=0;t<e.length;t++)n.push(e[t]);return n}static byteToString(t,r){return void 0===r&&(r="utf8"),Buffer.from(t).toString(r)}static intToBytes(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}static bytesToInt(t){return t[0]<<24|t[1]<<16|t[2]<<8|t[3]}static varintToInt(t){let r=[],n=[],e=3,i=0;for(let o=t.length-1;o>=0&&(n[0]=o-1>=0?t[o-1]<<7-i:0,-1!==e);o--)r[e]=(127&t[o])>>i|n[0],e--,i++;let o=r[0]<<24&4278190080|r[1]<<16&16711680|r[2]<<8&65280|255&r[3];return o=o>>1^-(1&o),o}static intToVarint(t){if(0===t)return[0];t=this._zigZagEncoding(t);let r,n=[],e=0;for(let i=5;i>0;i--)r=t>>7*(i-1)&127,0!==e&&(r|=128),0!==r&&n.push(r),e=r;return n}static varintToIntArray(t){let r,n=[],e=0,i=[];for(let o=0;o<t.length;o++)r=0|t[o]>>7&1,0===r&&e>0&&e<=5&&(i.push(this.varintToInt(n)),n=[],e=0),n.push(t[o]),e++;return i.push(this.varintToInt(n)),i}static intArrayToVarintBuffer(t){let r,n=[];for(let e=0;e<t.length;e++)r=this.intToVarint(t[e]),n.push(...r);return Buffer.from(n)}static _zigZagEncoding(t){return t>>31^t<<1}}}));