index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1682324647590, function(require, module, exports) {
  8. var undefined = (void 0); // Paranoia
  9. // Beyond this value, index getters/setters (i.e. array[0], array[1]) are so slow to
  10. // create, and consume so much memory, that the browser appears frozen.
  11. var MAX_ARRAY_LENGTH = 1e5;
  12. // Approximations of internal ECMAScript conversion functions
  13. var ECMAScript = (function() {
  14. // Stash a copy in case other scripts modify these
  15. var opts = Object.prototype.toString,
  16. ophop = Object.prototype.hasOwnProperty;
  17. return {
  18. // Class returns internal [[Class]] property, used to avoid cross-frame instanceof issues:
  19. Class: function(v) { return opts.call(v).replace(/^\[object *|\]$/g, ''); },
  20. HasProperty: function(o, p) { return p in o; },
  21. HasOwnProperty: function(o, p) { return ophop.call(o, p); },
  22. IsCallable: function(o) { return typeof o === 'function'; },
  23. ToInt32: function(v) { return v >> 0; },
  24. ToUint32: function(v) { return v >>> 0; }
  25. };
  26. }());
  27. // Snapshot intrinsics
  28. var LN2 = Math.LN2,
  29. abs = Math.abs,
  30. floor = Math.floor,
  31. log = Math.log,
  32. min = Math.min,
  33. pow = Math.pow,
  34. round = Math.round;
  35. // ES5: lock down object properties
  36. function configureProperties(obj) {
  37. if (getOwnPropNames && defineProp) {
  38. var props = getOwnPropNames(obj), i;
  39. for (i = 0; i < props.length; i += 1) {
  40. defineProp(obj, props[i], {
  41. value: obj[props[i]],
  42. writable: false,
  43. enumerable: false,
  44. configurable: false
  45. });
  46. }
  47. }
  48. }
  49. // emulate ES5 getter/setter API using legacy APIs
  50. // http://blogs.msdn.com/b/ie/archive/2010/09/07/transitioning-existing-code-to-the-es5-getter-setter-apis.aspx
  51. // (second clause tests for Object.defineProperty() in IE<9 that only supports extending DOM prototypes, but
  52. // note that IE<9 does not support __defineGetter__ or __defineSetter__ so it just renders the method harmless)
  53. var defineProp
  54. if (Object.defineProperty && (function() {
  55. try {
  56. Object.defineProperty({}, 'x', {});
  57. return true;
  58. } catch (e) {
  59. return false;
  60. }
  61. })()) {
  62. defineProp = Object.defineProperty;
  63. } else {
  64. defineProp = function(o, p, desc) {
  65. if (!o === Object(o)) throw new TypeError("Object.defineProperty called on non-object");
  66. if (ECMAScript.HasProperty(desc, 'get') && Object.prototype.__defineGetter__) { Object.prototype.__defineGetter__.call(o, p, desc.get); }
  67. if (ECMAScript.HasProperty(desc, 'set') && Object.prototype.__defineSetter__) { Object.prototype.__defineSetter__.call(o, p, desc.set); }
  68. if (ECMAScript.HasProperty(desc, 'value')) { o[p] = desc.value; }
  69. return o;
  70. };
  71. }
  72. var getOwnPropNames = Object.getOwnPropertyNames || function (o) {
  73. if (o !== Object(o)) throw new TypeError("Object.getOwnPropertyNames called on non-object");
  74. var props = [], p;
  75. for (p in o) {
  76. if (ECMAScript.HasOwnProperty(o, p)) {
  77. props.push(p);
  78. }
  79. }
  80. return props;
  81. };
  82. // ES5: Make obj[index] an alias for obj._getter(index)/obj._setter(index, value)
  83. // for index in 0 ... obj.length
  84. function makeArrayAccessors(obj) {
  85. if (!defineProp) { return; }
  86. if (obj.length > MAX_ARRAY_LENGTH) throw new RangeError("Array too large for polyfill");
  87. function makeArrayAccessor(index) {
  88. defineProp(obj, index, {
  89. 'get': function() { return obj._getter(index); },
  90. 'set': function(v) { obj._setter(index, v); },
  91. enumerable: true,
  92. configurable: false
  93. });
  94. }
  95. var i;
  96. for (i = 0; i < obj.length; i += 1) {
  97. makeArrayAccessor(i);
  98. }
  99. }
  100. // Internal conversion functions:
  101. // pack<Type>() - take a number (interpreted as Type), output a byte array
  102. // unpack<Type>() - take a byte array, output a Type-like number
  103. function as_signed(value, bits) { var s = 32 - bits; return (value << s) >> s; }
  104. function as_unsigned(value, bits) { var s = 32 - bits; return (value << s) >>> s; }
  105. function packI8(n) { return [n & 0xff]; }
  106. function unpackI8(bytes) { return as_signed(bytes[0], 8); }
  107. function packU8(n) { return [n & 0xff]; }
  108. function unpackU8(bytes) { return as_unsigned(bytes[0], 8); }
  109. function packU8Clamped(n) { n = round(Number(n)); return [n < 0 ? 0 : n > 0xff ? 0xff : n & 0xff]; }
  110. function packI16(n) { return [(n >> 8) & 0xff, n & 0xff]; }
  111. function unpackI16(bytes) { return as_signed(bytes[0] << 8 | bytes[1], 16); }
  112. function packU16(n) { return [(n >> 8) & 0xff, n & 0xff]; }
  113. function unpackU16(bytes) { return as_unsigned(bytes[0] << 8 | bytes[1], 16); }
  114. function packI32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; }
  115. function unpackI32(bytes) { return as_signed(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); }
  116. function packU32(n) { return [(n >> 24) & 0xff, (n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; }
  117. function unpackU32(bytes) { return as_unsigned(bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3], 32); }
  118. function packIEEE754(v, ebits, fbits) {
  119. var bias = (1 << (ebits - 1)) - 1,
  120. s, e, f, ln,
  121. i, bits, str, bytes;
  122. function roundToEven(n) {
  123. var w = floor(n), f = n - w;
  124. if (f < 0.5)
  125. return w;
  126. if (f > 0.5)
  127. return w + 1;
  128. return w % 2 ? w + 1 : w;
  129. }
  130. // Compute sign, exponent, fraction
  131. if (v !== v) {
  132. // NaN
  133. // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping
  134. e = (1 << ebits) - 1; f = pow(2, fbits - 1); s = 0;
  135. } else if (v === Infinity || v === -Infinity) {
  136. e = (1 << ebits) - 1; f = 0; s = (v < 0) ? 1 : 0;
  137. } else if (v === 0) {
  138. e = 0; f = 0; s = (1 / v === -Infinity) ? 1 : 0;
  139. } else {
  140. s = v < 0;
  141. v = abs(v);
  142. if (v >= pow(2, 1 - bias)) {
  143. e = min(floor(log(v) / LN2), 1023);
  144. f = roundToEven(v / pow(2, e) * pow(2, fbits));
  145. if (f / pow(2, fbits) >= 2) {
  146. e = e + 1;
  147. f = 1;
  148. }
  149. if (e > bias) {
  150. // Overflow
  151. e = (1 << ebits) - 1;
  152. f = 0;
  153. } else {
  154. // Normalized
  155. e = e + bias;
  156. f = f - pow(2, fbits);
  157. }
  158. } else {
  159. // Denormalized
  160. e = 0;
  161. f = roundToEven(v / pow(2, 1 - bias - fbits));
  162. }
  163. }
  164. // Pack sign, exponent, fraction
  165. bits = [];
  166. for (i = fbits; i; i -= 1) { bits.push(f % 2 ? 1 : 0); f = floor(f / 2); }
  167. for (i = ebits; i; i -= 1) { bits.push(e % 2 ? 1 : 0); e = floor(e / 2); }
  168. bits.push(s ? 1 : 0);
  169. bits.reverse();
  170. str = bits.join('');
  171. // Bits to bytes
  172. bytes = [];
  173. while (str.length) {
  174. bytes.push(parseInt(str.substring(0, 8), 2));
  175. str = str.substring(8);
  176. }
  177. return bytes;
  178. }
  179. function unpackIEEE754(bytes, ebits, fbits) {
  180. // Bytes to bits
  181. var bits = [], i, j, b, str,
  182. bias, s, e, f;
  183. for (i = bytes.length; i; i -= 1) {
  184. b = bytes[i - 1];
  185. for (j = 8; j; j -= 1) {
  186. bits.push(b % 2 ? 1 : 0); b = b >> 1;
  187. }
  188. }
  189. bits.reverse();
  190. str = bits.join('');
  191. // Unpack sign, exponent, fraction
  192. bias = (1 << (ebits - 1)) - 1;
  193. s = parseInt(str.substring(0, 1), 2) ? -1 : 1;
  194. e = parseInt(str.substring(1, 1 + ebits), 2);
  195. f = parseInt(str.substring(1 + ebits), 2);
  196. // Produce number
  197. if (e === (1 << ebits) - 1) {
  198. return f !== 0 ? NaN : s * Infinity;
  199. } else if (e > 0) {
  200. // Normalized
  201. return s * pow(2, e - bias) * (1 + f / pow(2, fbits));
  202. } else if (f !== 0) {
  203. // Denormalized
  204. return s * pow(2, -(bias - 1)) * (f / pow(2, fbits));
  205. } else {
  206. return s < 0 ? -0 : 0;
  207. }
  208. }
  209. function unpackF64(b) { return unpackIEEE754(b, 11, 52); }
  210. function packF64(v) { return packIEEE754(v, 11, 52); }
  211. function unpackF32(b) { return unpackIEEE754(b, 8, 23); }
  212. function packF32(v) { return packIEEE754(v, 8, 23); }
  213. //
  214. // 3 The ArrayBuffer Type
  215. //
  216. (function() {
  217. /** @constructor */
  218. var ArrayBuffer = function ArrayBuffer(length) {
  219. length = ECMAScript.ToInt32(length);
  220. if (length < 0) throw new RangeError('ArrayBuffer size is not a small enough positive integer');
  221. this.byteLength = length;
  222. this._bytes = [];
  223. this._bytes.length = length;
  224. var i;
  225. for (i = 0; i < this.byteLength; i += 1) {
  226. this._bytes[i] = 0;
  227. }
  228. configureProperties(this);
  229. };
  230. exports.ArrayBuffer = exports.ArrayBuffer || ArrayBuffer;
  231. //
  232. // 4 The ArrayBufferView Type
  233. //
  234. // NOTE: this constructor is not exported
  235. /** @constructor */
  236. var ArrayBufferView = function ArrayBufferView() {
  237. //this.buffer = null;
  238. //this.byteOffset = 0;
  239. //this.byteLength = 0;
  240. };
  241. //
  242. // 5 The Typed Array View Types
  243. //
  244. function makeConstructor(bytesPerElement, pack, unpack) {
  245. // Each TypedArray type requires a distinct constructor instance with
  246. // identical logic, which this produces.
  247. var ctor;
  248. ctor = function(buffer, byteOffset, length) {
  249. var array, sequence, i, s;
  250. if (!arguments.length || typeof arguments[0] === 'number') {
  251. // Constructor(unsigned long length)
  252. this.length = ECMAScript.ToInt32(arguments[0]);
  253. if (length < 0) throw new RangeError('ArrayBufferView size is not a small enough positive integer');
  254. this.byteLength = this.length * this.BYTES_PER_ELEMENT;
  255. this.buffer = new ArrayBuffer(this.byteLength);
  256. this.byteOffset = 0;
  257. } else if (typeof arguments[0] === 'object' && arguments[0].constructor === ctor) {
  258. // Constructor(TypedArray array)
  259. array = arguments[0];
  260. this.length = array.length;
  261. this.byteLength = this.length * this.BYTES_PER_ELEMENT;
  262. this.buffer = new ArrayBuffer(this.byteLength);
  263. this.byteOffset = 0;
  264. for (i = 0; i < this.length; i += 1) {
  265. this._setter(i, array._getter(i));
  266. }
  267. } else if (typeof arguments[0] === 'object' &&
  268. !(arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) {
  269. // Constructor(sequence<type> array)
  270. sequence = arguments[0];
  271. this.length = ECMAScript.ToUint32(sequence.length);
  272. this.byteLength = this.length * this.BYTES_PER_ELEMENT;
  273. this.buffer = new ArrayBuffer(this.byteLength);
  274. this.byteOffset = 0;
  275. for (i = 0; i < this.length; i += 1) {
  276. s = sequence[i];
  277. this._setter(i, Number(s));
  278. }
  279. } else if (typeof arguments[0] === 'object' &&
  280. (arguments[0] instanceof ArrayBuffer || ECMAScript.Class(arguments[0]) === 'ArrayBuffer')) {
  281. // Constructor(ArrayBuffer buffer,
  282. // optional unsigned long byteOffset, optional unsigned long length)
  283. this.buffer = buffer;
  284. this.byteOffset = ECMAScript.ToUint32(byteOffset);
  285. if (this.byteOffset > this.buffer.byteLength) {
  286. throw new RangeError("byteOffset out of range");
  287. }
  288. if (this.byteOffset % this.BYTES_PER_ELEMENT) {
  289. // The given byteOffset must be a multiple of the element
  290. // size of the specific type, otherwise an exception is raised.
  291. throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");
  292. }
  293. if (arguments.length < 3) {
  294. this.byteLength = this.buffer.byteLength - this.byteOffset;
  295. if (this.byteLength % this.BYTES_PER_ELEMENT) {
  296. throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");
  297. }
  298. this.length = this.byteLength / this.BYTES_PER_ELEMENT;
  299. } else {
  300. this.length = ECMAScript.ToUint32(length);
  301. this.byteLength = this.length * this.BYTES_PER_ELEMENT;
  302. }
  303. if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) {
  304. throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");
  305. }
  306. } else {
  307. throw new TypeError("Unexpected argument type(s)");
  308. }
  309. this.constructor = ctor;
  310. configureProperties(this);
  311. makeArrayAccessors(this);
  312. };
  313. ctor.prototype = new ArrayBufferView();
  314. ctor.prototype.BYTES_PER_ELEMENT = bytesPerElement;
  315. ctor.prototype._pack = pack;
  316. ctor.prototype._unpack = unpack;
  317. ctor.BYTES_PER_ELEMENT = bytesPerElement;
  318. // getter type (unsigned long index);
  319. ctor.prototype._getter = function(index) {
  320. if (arguments.length < 1) throw new SyntaxError("Not enough arguments");
  321. index = ECMAScript.ToUint32(index);
  322. if (index >= this.length) {
  323. return undefined;
  324. }
  325. var bytes = [], i, o;
  326. for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
  327. i < this.BYTES_PER_ELEMENT;
  328. i += 1, o += 1) {
  329. bytes.push(this.buffer._bytes[o]);
  330. }
  331. return this._unpack(bytes);
  332. };
  333. // NONSTANDARD: convenience alias for getter: type get(unsigned long index);
  334. ctor.prototype.get = ctor.prototype._getter;
  335. // setter void (unsigned long index, type value);
  336. ctor.prototype._setter = function(index, value) {
  337. if (arguments.length < 2) throw new SyntaxError("Not enough arguments");
  338. index = ECMAScript.ToUint32(index);
  339. if (index >= this.length) {
  340. return undefined;
  341. }
  342. var bytes = this._pack(value), i, o;
  343. for (i = 0, o = this.byteOffset + index * this.BYTES_PER_ELEMENT;
  344. i < this.BYTES_PER_ELEMENT;
  345. i += 1, o += 1) {
  346. this.buffer._bytes[o] = bytes[i];
  347. }
  348. };
  349. // void set(TypedArray array, optional unsigned long offset);
  350. // void set(sequence<type> array, optional unsigned long offset);
  351. ctor.prototype.set = function(index, value) {
  352. if (arguments.length < 1) throw new SyntaxError("Not enough arguments");
  353. var array, sequence, offset, len,
  354. i, s, d,
  355. byteOffset, byteLength, tmp;
  356. if (typeof arguments[0] === 'object' && arguments[0].constructor === this.constructor) {
  357. // void set(TypedArray array, optional unsigned long offset);
  358. array = arguments[0];
  359. offset = ECMAScript.ToUint32(arguments[1]);
  360. if (offset + array.length > this.length) {
  361. throw new RangeError("Offset plus length of array is out of range");
  362. }
  363. byteOffset = this.byteOffset + offset * this.BYTES_PER_ELEMENT;
  364. byteLength = array.length * this.BYTES_PER_ELEMENT;
  365. if (array.buffer === this.buffer) {
  366. tmp = [];
  367. for (i = 0, s = array.byteOffset; i < byteLength; i += 1, s += 1) {
  368. tmp[i] = array.buffer._bytes[s];
  369. }
  370. for (i = 0, d = byteOffset; i < byteLength; i += 1, d += 1) {
  371. this.buffer._bytes[d] = tmp[i];
  372. }
  373. } else {
  374. for (i = 0, s = array.byteOffset, d = byteOffset;
  375. i < byteLength; i += 1, s += 1, d += 1) {
  376. this.buffer._bytes[d] = array.buffer._bytes[s];
  377. }
  378. }
  379. } else if (typeof arguments[0] === 'object' && typeof arguments[0].length !== 'undefined') {
  380. // void set(sequence<type> array, optional unsigned long offset);
  381. sequence = arguments[0];
  382. len = ECMAScript.ToUint32(sequence.length);
  383. offset = ECMAScript.ToUint32(arguments[1]);
  384. if (offset + len > this.length) {
  385. throw new RangeError("Offset plus length of array is out of range");
  386. }
  387. for (i = 0; i < len; i += 1) {
  388. s = sequence[i];
  389. this._setter(offset + i, Number(s));
  390. }
  391. } else {
  392. throw new TypeError("Unexpected argument type(s)");
  393. }
  394. };
  395. // TypedArray subarray(long begin, optional long end);
  396. ctor.prototype.subarray = function(start, end) {
  397. function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
  398. start = ECMAScript.ToInt32(start);
  399. end = ECMAScript.ToInt32(end);
  400. if (arguments.length < 1) { start = 0; }
  401. if (arguments.length < 2) { end = this.length; }
  402. if (start < 0) { start = this.length + start; }
  403. if (end < 0) { end = this.length + end; }
  404. start = clamp(start, 0, this.length);
  405. end = clamp(end, 0, this.length);
  406. var len = end - start;
  407. if (len < 0) {
  408. len = 0;
  409. }
  410. return new this.constructor(
  411. this.buffer, this.byteOffset + start * this.BYTES_PER_ELEMENT, len);
  412. };
  413. return ctor;
  414. }
  415. var Int8Array = makeConstructor(1, packI8, unpackI8);
  416. var Uint8Array = makeConstructor(1, packU8, unpackU8);
  417. var Uint8ClampedArray = makeConstructor(1, packU8Clamped, unpackU8);
  418. var Int16Array = makeConstructor(2, packI16, unpackI16);
  419. var Uint16Array = makeConstructor(2, packU16, unpackU16);
  420. var Int32Array = makeConstructor(4, packI32, unpackI32);
  421. var Uint32Array = makeConstructor(4, packU32, unpackU32);
  422. var Float32Array = makeConstructor(4, packF32, unpackF32);
  423. var Float64Array = makeConstructor(8, packF64, unpackF64);
  424. exports.Int8Array = exports.Int8Array || Int8Array;
  425. exports.Uint8Array = exports.Uint8Array || Uint8Array;
  426. exports.Uint8ClampedArray = exports.Uint8ClampedArray || Uint8ClampedArray;
  427. exports.Int16Array = exports.Int16Array || Int16Array;
  428. exports.Uint16Array = exports.Uint16Array || Uint16Array;
  429. exports.Int32Array = exports.Int32Array || Int32Array;
  430. exports.Uint32Array = exports.Uint32Array || Uint32Array;
  431. exports.Float32Array = exports.Float32Array || Float32Array;
  432. exports.Float64Array = exports.Float64Array || Float64Array;
  433. }());
  434. //
  435. // 6 The DataView View Type
  436. //
  437. (function() {
  438. function r(array, index) {
  439. return ECMAScript.IsCallable(array.get) ? array.get(index) : array[index];
  440. }
  441. var IS_BIG_ENDIAN = (function() {
  442. var u16array = new(exports.Uint16Array)([0x1234]),
  443. u8array = new(exports.Uint8Array)(u16array.buffer);
  444. return r(u8array, 0) === 0x12;
  445. }());
  446. // Constructor(ArrayBuffer buffer,
  447. // optional unsigned long byteOffset,
  448. // optional unsigned long byteLength)
  449. /** @constructor */
  450. var DataView = function DataView(buffer, byteOffset, byteLength) {
  451. if (arguments.length === 0) {
  452. buffer = new exports.ArrayBuffer(0);
  453. } else if (!(buffer instanceof exports.ArrayBuffer || ECMAScript.Class(buffer) === 'ArrayBuffer')) {
  454. throw new TypeError("TypeError");
  455. }
  456. this.buffer = buffer || new exports.ArrayBuffer(0);
  457. this.byteOffset = ECMAScript.ToUint32(byteOffset);
  458. if (this.byteOffset > this.buffer.byteLength) {
  459. throw new RangeError("byteOffset out of range");
  460. }
  461. if (arguments.length < 3) {
  462. this.byteLength = this.buffer.byteLength - this.byteOffset;
  463. } else {
  464. this.byteLength = ECMAScript.ToUint32(byteLength);
  465. }
  466. if ((this.byteOffset + this.byteLength) > this.buffer.byteLength) {
  467. throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");
  468. }
  469. configureProperties(this);
  470. };
  471. function makeGetter(arrayType) {
  472. return function(byteOffset, littleEndian) {
  473. byteOffset = ECMAScript.ToUint32(byteOffset);
  474. if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) {
  475. throw new RangeError("Array index out of range");
  476. }
  477. byteOffset += this.byteOffset;
  478. var uint8Array = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT),
  479. bytes = [], i;
  480. for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) {
  481. bytes.push(r(uint8Array, i));
  482. }
  483. if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) {
  484. bytes.reverse();
  485. }
  486. return r(new arrayType(new exports.Uint8Array(bytes).buffer), 0);
  487. };
  488. }
  489. DataView.prototype.getUint8 = makeGetter(exports.Uint8Array);
  490. DataView.prototype.getInt8 = makeGetter(exports.Int8Array);
  491. DataView.prototype.getUint16 = makeGetter(exports.Uint16Array);
  492. DataView.prototype.getInt16 = makeGetter(exports.Int16Array);
  493. DataView.prototype.getUint32 = makeGetter(exports.Uint32Array);
  494. DataView.prototype.getInt32 = makeGetter(exports.Int32Array);
  495. DataView.prototype.getFloat32 = makeGetter(exports.Float32Array);
  496. DataView.prototype.getFloat64 = makeGetter(exports.Float64Array);
  497. function makeSetter(arrayType) {
  498. return function(byteOffset, value, littleEndian) {
  499. byteOffset = ECMAScript.ToUint32(byteOffset);
  500. if (byteOffset + arrayType.BYTES_PER_ELEMENT > this.byteLength) {
  501. throw new RangeError("Array index out of range");
  502. }
  503. // Get bytes
  504. var typeArray = new arrayType([value]),
  505. byteArray = new exports.Uint8Array(typeArray.buffer),
  506. bytes = [], i, byteView;
  507. for (i = 0; i < arrayType.BYTES_PER_ELEMENT; i += 1) {
  508. bytes.push(r(byteArray, i));
  509. }
  510. // Flip if necessary
  511. if (Boolean(littleEndian) === Boolean(IS_BIG_ENDIAN)) {
  512. bytes.reverse();
  513. }
  514. // Write them
  515. byteView = new exports.Uint8Array(this.buffer, byteOffset, arrayType.BYTES_PER_ELEMENT);
  516. byteView.set(bytes);
  517. };
  518. }
  519. DataView.prototype.setUint8 = makeSetter(exports.Uint8Array);
  520. DataView.prototype.setInt8 = makeSetter(exports.Int8Array);
  521. DataView.prototype.setUint16 = makeSetter(exports.Uint16Array);
  522. DataView.prototype.setInt16 = makeSetter(exports.Int16Array);
  523. DataView.prototype.setUint32 = makeSetter(exports.Uint32Array);
  524. DataView.prototype.setInt32 = makeSetter(exports.Int32Array);
  525. DataView.prototype.setFloat32 = makeSetter(exports.Float32Array);
  526. DataView.prototype.setFloat64 = makeSetter(exports.Float64Array);
  527. exports.DataView = exports.DataView || DataView;
  528. }());
  529. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  530. return __REQUIRE__(1682324647590);
  531. })()
  532. //miniprogram-npm-outsideDeps=[]
  533. //# sourceMappingURL=index.js.map