qa-regulatory-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/Buffer.js

8 lines
19 KiB
JavaScript
Raw Normal View History

2023-11-07 10:04:37 +08:00
define(["./base64","./ieee754","./isArray"],(function(t,r,e){"use strict";
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/function n(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,r){if(n()<r)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=o.prototype:(null===t&&(t=new o(r)),t.length=r),t}function o(t,r,e){if(!(o.TYPED_ARRAY_SUPPORT||this instanceof o))return new o(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return s(this,t)}return u(this,t,r,e)}function u(t,r,n,u){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n);o.TYPED_ARRAY_SUPPORT?(t=r).__proto__=o.prototype:t=h(t,r);return t}(t,r,n,u):"string"==typeof r?function(t,r,e){"string"==typeof e&&""!==e||(e="utf8");if(!o.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|l(r,e),u=(t=i(t,n)).write(r,e);u!==n&&(t=t.slice(0,u));return t}(t,r,n):function(t,r){if(c(r)){var n=0|a(r.length);return 0===(t=i(t,n)).length||r.copy(t,0,0,n),t}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(o=r.length)!=o?i(t,0):h(t,r);if("Buffer"===r.type&&e(r.data))return h(t,r.data)}var o;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function s(t,r){if(f(r),t=i(t,r<0?0:0|a(r)),!o.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function h(t,r){var e=r.length<0?0:0|a(r.length);t=i(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function a(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function c(t){return!(null==t||!t._isBuffer)}function l(t,r){if(c(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return F(t).length;default:if(n)return z(t).length;r=(""+r).toLowerCase(),n=!0}}function p(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,r,e);case"utf8":case"utf-8":return _(this,r,e);case"ascii":return T(this,r,e);case"latin1":case"binary":return B(this,r,e);case"base64":return m(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function y(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof r&&(r=o.from(r,n)),c(r))return 0===r.length?-1:w(t,r,e,n,i);if("number"==typeof r)return r&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):w(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,r,e,n,i){var o,u=1,f=t.length,s=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"==