@ohif/app 3.10.0-beta.82 → 3.10.0-beta.84

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.
Files changed (60) hide show
  1. package/dist/1429.bundle.0458a6327b8d6f48e7f6.js +2079 -0
  2. package/dist/{1919.bundle.fac1a1d5ed506f80403a.js → 1919.bundle.be10898e6eacf985f751.js} +3 -2
  3. package/dist/{1927.bundle.81b7ac9fa6e3ae8aba5a.js → 1927.bundle.3b172968ee6878d78f9e.js} +4 -8
  4. package/dist/{213.bundle.fa2e8e690664bf6be377.js → 213.bundle.4eed9eba462fadcf00ed.js} +1 -1
  5. package/dist/{2424.bundle.b4ac6b4c605850932c35.js → 2424.bundle.c12487f5cd72c5ee6d15.js} +1 -1
  6. package/dist/{2701.bundle.151bc3d7c101e4f6f775.js → 2701.bundle.a2b2d200a6d455de3371.js} +2 -2
  7. package/dist/{2712.bundle.c699447e74e43c93de8c.js → 2712.bundle.d4fc8a3969caa7717a68.js} +18 -9
  8. package/dist/{2825.bundle.45d5a8895b6c835c16ae.js → 2825.bundle.fbd4a5321edc495a4ce0.js} +1 -1
  9. package/dist/{3334.bundle.e36011d0fd5fcb7e8b84.js → 3334.bundle.95de16b9f8539a9195e5.js} +1 -1
  10. package/dist/{3353.bundle.7b884aa0f7a26146cbed.js → 3353.bundle.4f0b079518d4e63a38d7.js} +3573 -3
  11. package/dist/{3677.bundle.d3c30c37d00fc58b4442.js → 3677.bundle.22ecea02fae99fc4b073.js} +1 -1
  12. package/dist/{4202.bundle.0caa856ac58e5c08f2b4.js → 4202.bundle.2d6a9c611b69fe6fde95.js} +2 -2
  13. package/dist/{4526.bundle.6e1a7b8e12adcff47cdd.js → 4526.bundle.bd735e55f7488c90a925.js} +2 -2
  14. package/dist/{4759.bundle.f4683c6bbb72fd79db48.js → 4759.bundle.0d60078f58f5a56c0157.js} +2 -1
  15. package/dist/{4834.bundle.432fad75b5bb54e884f3.js → 4834.bundle.1cd5fb62c2b84dedca74.js} +1 -1
  16. package/dist/{4991.bundle.3e1460e703ed405e44d1.js → 4991.bundle.aa561005b9bff1f391af.js} +103 -86
  17. package/dist/{5038.bundle.ba16b298b06579c34e6f.js → 5038.bundle.d674ce2b1fc4c4a2cbfd.js} +1973 -12
  18. package/dist/{5247.bundle.d0400f68884686944810.js → 5247.bundle.76d674c09cbd09fe768a.js} +2 -2
  19. package/dist/{5261.bundle.54d7af66923a3bae707d.js → 5261.bundle.5454fb98c87e3e21b419.js} +1 -1
  20. package/dist/5502.bundle.6426efd96b9b596dc43a.js +1357 -0
  21. package/dist/{5674.bundle.c12a7e754ef95a8123ab.js → 5674.bundle.05e639d0871778c8093a.js} +2 -1
  22. package/dist/{573.bundle.d08dcb8e65e3b7729b58.js → 573.bundle.ae0bd4f3e1f4eac8ae43.js} +3 -651
  23. package/dist/{5770.bundle.5eb1bc6bbde0faa09847.js → 5770.bundle.3548179e63f43f477f07.js} +2 -2
  24. package/dist/{6027.bundle.b98ce566f43e456b4173.js → 6027.bundle.de9a12716a59854fc16c.js} +2 -2
  25. package/dist/{6201.bundle.615164b109931db9bcdb.js → 6201.bundle.2b8031107607ac590622.js} +1 -1
  26. package/dist/642.bundle.93776d787135fbeb83da.js +2725 -0
  27. package/dist/{6734.bundle.a7cd598e47f99e8d6373.js → 6734.bundle.b3c44469591d79c42860.js} +1 -1
  28. package/dist/{6896.bundle.e0149d4d95293b20e3dc.js → 6896.bundle.cd44d8d0f50212a6e3bf.js} +2 -1
  29. package/dist/{6939.bundle.5e77a634e8784085c00e.js → 6939.bundle.35a07bed912bc04c9d75.js} +1 -1
  30. package/dist/{7100.bundle.cd391522079b32dffcbb.js → 7100.bundle.980541bb01d1410d76f7.js} +4 -4
  31. package/dist/{7159.bundle.4ee84ebbce84383e30d4.js → 7159.bundle.1761513105b61524f649.js} +1 -1
  32. package/dist/{7197.bundle.e7095f9357e769e319b7.js → 7197.bundle.18ef9259965009898004.js} +1 -1
  33. package/dist/{732.bundle.532947c280e1a8f6e020.js → 732.bundle.6978ac30a1e36abf06db.js} +1 -1
  34. package/dist/{7490.bundle.cd06395fa95af35af407.js → 7490.bundle.d63d4937661b960d6066.js} +8 -5
  35. package/dist/{7955.bundle.39b44e7c1ec2b58ebd68.js → 7955.bundle.2d56e839ad167c1fe4eb.js} +1 -1
  36. package/dist/{8008.bundle.097a655dd5e2ae358b1e.js → 8008.bundle.ad4abef7b197d8c15b1f.js} +1 -1
  37. package/dist/{8094.bundle.411698eaf81975a7f12d.js → 8094.bundle.5c44190a325ac23e3e5c.js} +1 -1
  38. package/dist/{810.bundle.bf1e31f46b7a3651c17f.js → 810.bundle.4f53cfc8fada137c10f3.js} +2 -2
  39. package/dist/{8228.bundle.129df17dd2bc84f78f0f.js → 8228.bundle.d38bd3ea6affcbb2717c.js} +2 -2
  40. package/dist/{8259.bundle.4bd912519dc7eb989a66.js → 8259.bundle.af80469d543047c69966.js} +2 -2
  41. package/dist/{8558.bundle.2d0f8c3f1446f38b0389.js → 8558.bundle.fd5ca18925955e673343.js} +3 -2
  42. package/dist/{870.bundle.024b7cfba334275def69.js → 870.bundle.1edba777506313d2e514.js} +3 -3
  43. package/dist/{9026.bundle.41edb0323d93c66b4a50.js → 9026.bundle.b15ddd173600c3bdcd64.js} +2 -2
  44. package/dist/9026.css +1 -1
  45. package/dist/{9113.bundle.ea06cd5c0417be2096fd.js → 9113.bundle.dd644aa37c1f8d642e61.js} +7 -1
  46. package/dist/{9196.bundle.23880ce013c5d3794c88.js → 9196.bundle.06e751e6da707cb0a645.js} +98 -37
  47. package/dist/{9551.bundle.73179f386cbbf1f343c5.js → 9551.bundle.d576a433c0ad17642d98.js} +1 -1
  48. package/dist/{9677.bundle.d09a4e387931be7c1804.js → 9677.bundle.3f0630d50368500cb184.js} +105 -36
  49. package/dist/{9862.bundle.f8c7e257c37da16d21ae.js → 9862.bundle.7ab3a03b659070ff633e.js} +2 -2
  50. package/dist/{9890.bundle.de10e3da396222898d2a.js → 9890.bundle.10edee7d748b2688ef1f.js} +2 -2
  51. package/dist/a957c5cd315f89b6feb1.wasm +0 -0
  52. package/dist/app.bundle.css +14 -14
  53. package/dist/{app.bundle.60172a09ca51ec1a3ee2.js → app.bundle.e9bd40872d3780ff15f7.js} +4785 -881
  54. package/dist/{histogram-worker.bundle.f978654858500a3080cc.js → histogram-worker.bundle.6b0dbbdb168d711efad4.js} +4 -8
  55. package/dist/index.html +1 -1
  56. package/dist/{polySeg.bundle.4c7da20a2061038ede40.js → polySeg.bundle.f85c2393a03d323db35b.js} +4 -8
  57. package/dist/{suv-peak-worker.bundle.6b3b00ebe4bba9f01673.js → suv-peak-worker.bundle.c5b7f9f39d56d0283b0e.js} +6 -10
  58. package/dist/sw.js +1 -1
  59. package/package.json +18 -18
  60. package/dist/20fc4c659b85ccd2a9c0.wasm +0 -0
@@ -0,0 +1,2079 @@
1
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[1429],{
2
+
3
+ /***/ 54028:
4
+ /***/ ((__unused_webpack_module, exports) => {
5
+
6
+ "use strict";
7
+
8
+
9
+ exports.byteLength = byteLength
10
+ exports.toByteArray = toByteArray
11
+ exports.fromByteArray = fromByteArray
12
+
13
+ var lookup = []
14
+ var revLookup = []
15
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
16
+
17
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
18
+ for (var i = 0, len = code.length; i < len; ++i) {
19
+ lookup[i] = code[i]
20
+ revLookup[code.charCodeAt(i)] = i
21
+ }
22
+
23
+ // Support decoding URL-safe base64 strings, as Node.js does.
24
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
25
+ revLookup['-'.charCodeAt(0)] = 62
26
+ revLookup['_'.charCodeAt(0)] = 63
27
+
28
+ function getLens (b64) {
29
+ var len = b64.length
30
+
31
+ if (len % 4 > 0) {
32
+ throw new Error('Invalid string. Length must be a multiple of 4')
33
+ }
34
+
35
+ // Trim off extra bytes after placeholder bytes are found
36
+ // See: https://github.com/beatgammit/base64-js/issues/42
37
+ var validLen = b64.indexOf('=')
38
+ if (validLen === -1) validLen = len
39
+
40
+ var placeHoldersLen = validLen === len
41
+ ? 0
42
+ : 4 - (validLen % 4)
43
+
44
+ return [validLen, placeHoldersLen]
45
+ }
46
+
47
+ // base64 is 4/3 + up to two characters of the original data
48
+ function byteLength (b64) {
49
+ var lens = getLens(b64)
50
+ var validLen = lens[0]
51
+ var placeHoldersLen = lens[1]
52
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
53
+ }
54
+
55
+ function _byteLength (b64, validLen, placeHoldersLen) {
56
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
57
+ }
58
+
59
+ function toByteArray (b64) {
60
+ var tmp
61
+ var lens = getLens(b64)
62
+ var validLen = lens[0]
63
+ var placeHoldersLen = lens[1]
64
+
65
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
66
+
67
+ var curByte = 0
68
+
69
+ // if there are placeholders, only get up to the last complete 4 chars
70
+ var len = placeHoldersLen > 0
71
+ ? validLen - 4
72
+ : validLen
73
+
74
+ var i
75
+ for (i = 0; i < len; i += 4) {
76
+ tmp =
77
+ (revLookup[b64.charCodeAt(i)] << 18) |
78
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
79
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
80
+ revLookup[b64.charCodeAt(i + 3)]
81
+ arr[curByte++] = (tmp >> 16) & 0xFF
82
+ arr[curByte++] = (tmp >> 8) & 0xFF
83
+ arr[curByte++] = tmp & 0xFF
84
+ }
85
+
86
+ if (placeHoldersLen === 2) {
87
+ tmp =
88
+ (revLookup[b64.charCodeAt(i)] << 2) |
89
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
90
+ arr[curByte++] = tmp & 0xFF
91
+ }
92
+
93
+ if (placeHoldersLen === 1) {
94
+ tmp =
95
+ (revLookup[b64.charCodeAt(i)] << 10) |
96
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
97
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
98
+ arr[curByte++] = (tmp >> 8) & 0xFF
99
+ arr[curByte++] = tmp & 0xFF
100
+ }
101
+
102
+ return arr
103
+ }
104
+
105
+ function tripletToBase64 (num) {
106
+ return lookup[num >> 18 & 0x3F] +
107
+ lookup[num >> 12 & 0x3F] +
108
+ lookup[num >> 6 & 0x3F] +
109
+ lookup[num & 0x3F]
110
+ }
111
+
112
+ function encodeChunk (uint8, start, end) {
113
+ var tmp
114
+ var output = []
115
+ for (var i = start; i < end; i += 3) {
116
+ tmp =
117
+ ((uint8[i] << 16) & 0xFF0000) +
118
+ ((uint8[i + 1] << 8) & 0xFF00) +
119
+ (uint8[i + 2] & 0xFF)
120
+ output.push(tripletToBase64(tmp))
121
+ }
122
+ return output.join('')
123
+ }
124
+
125
+ function fromByteArray (uint8) {
126
+ var tmp
127
+ var len = uint8.length
128
+ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
129
+ var parts = []
130
+ var maxChunkLength = 16383 // must be multiple of 3
131
+
132
+ // go through the array every three bytes, we'll deal with trailing stuff later
133
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
134
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
135
+ }
136
+
137
+ // pad the end with zeros, but make sure to not forget the extra bytes
138
+ if (extraBytes === 1) {
139
+ tmp = uint8[len - 1]
140
+ parts.push(
141
+ lookup[tmp >> 2] +
142
+ lookup[(tmp << 4) & 0x3F] +
143
+ '=='
144
+ )
145
+ } else if (extraBytes === 2) {
146
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
147
+ parts.push(
148
+ lookup[tmp >> 10] +
149
+ lookup[(tmp >> 4) & 0x3F] +
150
+ lookup[(tmp << 2) & 0x3F] +
151
+ '='
152
+ )
153
+ }
154
+
155
+ return parts.join('')
156
+ }
157
+
158
+
159
+ /***/ }),
160
+
161
+ /***/ 81429:
162
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
163
+
164
+ "use strict";
165
+ var __webpack_unused_export__;
166
+ /*!
167
+ * The buffer module from node.js, for the browser.
168
+ *
169
+ * @author Feross Aboukhadijeh <https://feross.org>
170
+ * @license MIT
171
+ */
172
+ /* eslint-disable no-proto */
173
+
174
+
175
+
176
+ var base64 = __webpack_require__(54028)
177
+ var ieee754 = __webpack_require__(55801)
178
+ var customInspectSymbol =
179
+ (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
180
+ ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
181
+ : null
182
+
183
+ exports.hp = Buffer
184
+ __webpack_unused_export__ = SlowBuffer
185
+ exports.IS = 50
186
+
187
+ var K_MAX_LENGTH = 0x7fffffff
188
+ __webpack_unused_export__ = K_MAX_LENGTH
189
+
190
+ /**
191
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
192
+ * === true Use Uint8Array implementation (fastest)
193
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
194
+ * implementation (most compatible, even IE6)
195
+ *
196
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
197
+ * Opera 11.6+, iOS 4.2+.
198
+ *
199
+ * We report that the browser does not support typed arrays if the are not subclassable
200
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
201
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
202
+ * for __proto__ and has a buggy typed array implementation.
203
+ */
204
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
205
+
206
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
207
+ typeof console.error === 'function') {
208
+ console.error(
209
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
210
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
211
+ )
212
+ }
213
+
214
+ function typedArraySupport () {
215
+ // Can typed array instances can be augmented?
216
+ try {
217
+ var arr = new Uint8Array(1)
218
+ var proto = { foo: function () { return 42 } }
219
+ Object.setPrototypeOf(proto, Uint8Array.prototype)
220
+ Object.setPrototypeOf(arr, proto)
221
+ return arr.foo() === 42
222
+ } catch (e) {
223
+ return false
224
+ }
225
+ }
226
+
227
+ Object.defineProperty(Buffer.prototype, 'parent', {
228
+ enumerable: true,
229
+ get: function () {
230
+ if (!Buffer.isBuffer(this)) return undefined
231
+ return this.buffer
232
+ }
233
+ })
234
+
235
+ Object.defineProperty(Buffer.prototype, 'offset', {
236
+ enumerable: true,
237
+ get: function () {
238
+ if (!Buffer.isBuffer(this)) return undefined
239
+ return this.byteOffset
240
+ }
241
+ })
242
+
243
+ function createBuffer (length) {
244
+ if (length > K_MAX_LENGTH) {
245
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
246
+ }
247
+ // Return an augmented `Uint8Array` instance
248
+ var buf = new Uint8Array(length)
249
+ Object.setPrototypeOf(buf, Buffer.prototype)
250
+ return buf
251
+ }
252
+
253
+ /**
254
+ * The Buffer constructor returns instances of `Uint8Array` that have their
255
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
256
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
257
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
258
+ * returns a single octet.
259
+ *
260
+ * The `Uint8Array` prototype remains unmodified.
261
+ */
262
+
263
+ function Buffer (arg, encodingOrOffset, length) {
264
+ // Common case.
265
+ if (typeof arg === 'number') {
266
+ if (typeof encodingOrOffset === 'string') {
267
+ throw new TypeError(
268
+ 'The "string" argument must be of type string. Received type number'
269
+ )
270
+ }
271
+ return allocUnsafe(arg)
272
+ }
273
+ return from(arg, encodingOrOffset, length)
274
+ }
275
+
276
+ Buffer.poolSize = 8192 // not used by this implementation
277
+
278
+ function from (value, encodingOrOffset, length) {
279
+ if (typeof value === 'string') {
280
+ return fromString(value, encodingOrOffset)
281
+ }
282
+
283
+ if (ArrayBuffer.isView(value)) {
284
+ return fromArrayView(value)
285
+ }
286
+
287
+ if (value == null) {
288
+ throw new TypeError(
289
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
290
+ 'or Array-like Object. Received type ' + (typeof value)
291
+ )
292
+ }
293
+
294
+ if (isInstance(value, ArrayBuffer) ||
295
+ (value && isInstance(value.buffer, ArrayBuffer))) {
296
+ return fromArrayBuffer(value, encodingOrOffset, length)
297
+ }
298
+
299
+ if (typeof SharedArrayBuffer !== 'undefined' &&
300
+ (isInstance(value, SharedArrayBuffer) ||
301
+ (value && isInstance(value.buffer, SharedArrayBuffer)))) {
302
+ return fromArrayBuffer(value, encodingOrOffset, length)
303
+ }
304
+
305
+ if (typeof value === 'number') {
306
+ throw new TypeError(
307
+ 'The "value" argument must not be of type number. Received type number'
308
+ )
309
+ }
310
+
311
+ var valueOf = value.valueOf && value.valueOf()
312
+ if (valueOf != null && valueOf !== value) {
313
+ return Buffer.from(valueOf, encodingOrOffset, length)
314
+ }
315
+
316
+ var b = fromObject(value)
317
+ if (b) return b
318
+
319
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
320
+ typeof value[Symbol.toPrimitive] === 'function') {
321
+ return Buffer.from(
322
+ value[Symbol.toPrimitive]('string'), encodingOrOffset, length
323
+ )
324
+ }
325
+
326
+ throw new TypeError(
327
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
328
+ 'or Array-like Object. Received type ' + (typeof value)
329
+ )
330
+ }
331
+
332
+ /**
333
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
334
+ * if value is a number.
335
+ * Buffer.from(str[, encoding])
336
+ * Buffer.from(array)
337
+ * Buffer.from(buffer)
338
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
339
+ **/
340
+ Buffer.from = function (value, encodingOrOffset, length) {
341
+ return from(value, encodingOrOffset, length)
342
+ }
343
+
344
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
345
+ // https://github.com/feross/buffer/pull/148
346
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
347
+ Object.setPrototypeOf(Buffer, Uint8Array)
348
+
349
+ function assertSize (size) {
350
+ if (typeof size !== 'number') {
351
+ throw new TypeError('"size" argument must be of type number')
352
+ } else if (size < 0) {
353
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
354
+ }
355
+ }
356
+
357
+ function alloc (size, fill, encoding) {
358
+ assertSize(size)
359
+ if (size <= 0) {
360
+ return createBuffer(size)
361
+ }
362
+ if (fill !== undefined) {
363
+ // Only pay attention to encoding if it's a string. This
364
+ // prevents accidentally sending in a number that would
365
+ // be interpreted as a start offset.
366
+ return typeof encoding === 'string'
367
+ ? createBuffer(size).fill(fill, encoding)
368
+ : createBuffer(size).fill(fill)
369
+ }
370
+ return createBuffer(size)
371
+ }
372
+
373
+ /**
374
+ * Creates a new filled Buffer instance.
375
+ * alloc(size[, fill[, encoding]])
376
+ **/
377
+ Buffer.alloc = function (size, fill, encoding) {
378
+ return alloc(size, fill, encoding)
379
+ }
380
+
381
+ function allocUnsafe (size) {
382
+ assertSize(size)
383
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
384
+ }
385
+
386
+ /**
387
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
388
+ * */
389
+ Buffer.allocUnsafe = function (size) {
390
+ return allocUnsafe(size)
391
+ }
392
+ /**
393
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
394
+ */
395
+ Buffer.allocUnsafeSlow = function (size) {
396
+ return allocUnsafe(size)
397
+ }
398
+
399
+ function fromString (string, encoding) {
400
+ if (typeof encoding !== 'string' || encoding === '') {
401
+ encoding = 'utf8'
402
+ }
403
+
404
+ if (!Buffer.isEncoding(encoding)) {
405
+ throw new TypeError('Unknown encoding: ' + encoding)
406
+ }
407
+
408
+ var length = byteLength(string, encoding) | 0
409
+ var buf = createBuffer(length)
410
+
411
+ var actual = buf.write(string, encoding)
412
+
413
+ if (actual !== length) {
414
+ // Writing a hex string, for example, that contains invalid characters will
415
+ // cause everything after the first invalid character to be ignored. (e.g.
416
+ // 'abxxcd' will be treated as 'ab')
417
+ buf = buf.slice(0, actual)
418
+ }
419
+
420
+ return buf
421
+ }
422
+
423
+ function fromArrayLike (array) {
424
+ var length = array.length < 0 ? 0 : checked(array.length) | 0
425
+ var buf = createBuffer(length)
426
+ for (var i = 0; i < length; i += 1) {
427
+ buf[i] = array[i] & 255
428
+ }
429
+ return buf
430
+ }
431
+
432
+ function fromArrayView (arrayView) {
433
+ if (isInstance(arrayView, Uint8Array)) {
434
+ var copy = new Uint8Array(arrayView)
435
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
436
+ }
437
+ return fromArrayLike(arrayView)
438
+ }
439
+
440
+ function fromArrayBuffer (array, byteOffset, length) {
441
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
442
+ throw new RangeError('"offset" is outside of buffer bounds')
443
+ }
444
+
445
+ if (array.byteLength < byteOffset + (length || 0)) {
446
+ throw new RangeError('"length" is outside of buffer bounds')
447
+ }
448
+
449
+ var buf
450
+ if (byteOffset === undefined && length === undefined) {
451
+ buf = new Uint8Array(array)
452
+ } else if (length === undefined) {
453
+ buf = new Uint8Array(array, byteOffset)
454
+ } else {
455
+ buf = new Uint8Array(array, byteOffset, length)
456
+ }
457
+
458
+ // Return an augmented `Uint8Array` instance
459
+ Object.setPrototypeOf(buf, Buffer.prototype)
460
+
461
+ return buf
462
+ }
463
+
464
+ function fromObject (obj) {
465
+ if (Buffer.isBuffer(obj)) {
466
+ var len = checked(obj.length) | 0
467
+ var buf = createBuffer(len)
468
+
469
+ if (buf.length === 0) {
470
+ return buf
471
+ }
472
+
473
+ obj.copy(buf, 0, 0, len)
474
+ return buf
475
+ }
476
+
477
+ if (obj.length !== undefined) {
478
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
479
+ return createBuffer(0)
480
+ }
481
+ return fromArrayLike(obj)
482
+ }
483
+
484
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
485
+ return fromArrayLike(obj.data)
486
+ }
487
+ }
488
+
489
+ function checked (length) {
490
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
491
+ // length is NaN (which is otherwise coerced to zero.)
492
+ if (length >= K_MAX_LENGTH) {
493
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
494
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
495
+ }
496
+ return length | 0
497
+ }
498
+
499
+ function SlowBuffer (length) {
500
+ if (+length != length) { // eslint-disable-line eqeqeq
501
+ length = 0
502
+ }
503
+ return Buffer.alloc(+length)
504
+ }
505
+
506
+ Buffer.isBuffer = function isBuffer (b) {
507
+ return b != null && b._isBuffer === true &&
508
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
509
+ }
510
+
511
+ Buffer.compare = function compare (a, b) {
512
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
513
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
514
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
515
+ throw new TypeError(
516
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
517
+ )
518
+ }
519
+
520
+ if (a === b) return 0
521
+
522
+ var x = a.length
523
+ var y = b.length
524
+
525
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
526
+ if (a[i] !== b[i]) {
527
+ x = a[i]
528
+ y = b[i]
529
+ break
530
+ }
531
+ }
532
+
533
+ if (x < y) return -1
534
+ if (y < x) return 1
535
+ return 0
536
+ }
537
+
538
+ Buffer.isEncoding = function isEncoding (encoding) {
539
+ switch (String(encoding).toLowerCase()) {
540
+ case 'hex':
541
+ case 'utf8':
542
+ case 'utf-8':
543
+ case 'ascii':
544
+ case 'latin1':
545
+ case 'binary':
546
+ case 'base64':
547
+ case 'ucs2':
548
+ case 'ucs-2':
549
+ case 'utf16le':
550
+ case 'utf-16le':
551
+ return true
552
+ default:
553
+ return false
554
+ }
555
+ }
556
+
557
+ Buffer.concat = function concat (list, length) {
558
+ if (!Array.isArray(list)) {
559
+ throw new TypeError('"list" argument must be an Array of Buffers')
560
+ }
561
+
562
+ if (list.length === 0) {
563
+ return Buffer.alloc(0)
564
+ }
565
+
566
+ var i
567
+ if (length === undefined) {
568
+ length = 0
569
+ for (i = 0; i < list.length; ++i) {
570
+ length += list[i].length
571
+ }
572
+ }
573
+
574
+ var buffer = Buffer.allocUnsafe(length)
575
+ var pos = 0
576
+ for (i = 0; i < list.length; ++i) {
577
+ var buf = list[i]
578
+ if (isInstance(buf, Uint8Array)) {
579
+ if (pos + buf.length > buffer.length) {
580
+ Buffer.from(buf).copy(buffer, pos)
581
+ } else {
582
+ Uint8Array.prototype.set.call(
583
+ buffer,
584
+ buf,
585
+ pos
586
+ )
587
+ }
588
+ } else if (!Buffer.isBuffer(buf)) {
589
+ throw new TypeError('"list" argument must be an Array of Buffers')
590
+ } else {
591
+ buf.copy(buffer, pos)
592
+ }
593
+ pos += buf.length
594
+ }
595
+ return buffer
596
+ }
597
+
598
+ function byteLength (string, encoding) {
599
+ if (Buffer.isBuffer(string)) {
600
+ return string.length
601
+ }
602
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
603
+ return string.byteLength
604
+ }
605
+ if (typeof string !== 'string') {
606
+ throw new TypeError(
607
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
608
+ 'Received type ' + typeof string
609
+ )
610
+ }
611
+
612
+ var len = string.length
613
+ var mustMatch = (arguments.length > 2 && arguments[2] === true)
614
+ if (!mustMatch && len === 0) return 0
615
+
616
+ // Use a for loop to avoid recursion
617
+ var loweredCase = false
618
+ for (;;) {
619
+ switch (encoding) {
620
+ case 'ascii':
621
+ case 'latin1':
622
+ case 'binary':
623
+ return len
624
+ case 'utf8':
625
+ case 'utf-8':
626
+ return utf8ToBytes(string).length
627
+ case 'ucs2':
628
+ case 'ucs-2':
629
+ case 'utf16le':
630
+ case 'utf-16le':
631
+ return len * 2
632
+ case 'hex':
633
+ return len >>> 1
634
+ case 'base64':
635
+ return base64ToBytes(string).length
636
+ default:
637
+ if (loweredCase) {
638
+ return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
639
+ }
640
+ encoding = ('' + encoding).toLowerCase()
641
+ loweredCase = true
642
+ }
643
+ }
644
+ }
645
+ Buffer.byteLength = byteLength
646
+
647
+ function slowToString (encoding, start, end) {
648
+ var loweredCase = false
649
+
650
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
651
+ // property of a typed array.
652
+
653
+ // This behaves neither like String nor Uint8Array in that we set start/end
654
+ // to their upper/lower bounds if the value passed is out of range.
655
+ // undefined is handled specially as per ECMA-262 6th Edition,
656
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
657
+ if (start === undefined || start < 0) {
658
+ start = 0
659
+ }
660
+ // Return early if start > this.length. Done here to prevent potential uint32
661
+ // coercion fail below.
662
+ if (start > this.length) {
663
+ return ''
664
+ }
665
+
666
+ if (end === undefined || end > this.length) {
667
+ end = this.length
668
+ }
669
+
670
+ if (end <= 0) {
671
+ return ''
672
+ }
673
+
674
+ // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
675
+ end >>>= 0
676
+ start >>>= 0
677
+
678
+ if (end <= start) {
679
+ return ''
680
+ }
681
+
682
+ if (!encoding) encoding = 'utf8'
683
+
684
+ while (true) {
685
+ switch (encoding) {
686
+ case 'hex':
687
+ return hexSlice(this, start, end)
688
+
689
+ case 'utf8':
690
+ case 'utf-8':
691
+ return utf8Slice(this, start, end)
692
+
693
+ case 'ascii':
694
+ return asciiSlice(this, start, end)
695
+
696
+ case 'latin1':
697
+ case 'binary':
698
+ return latin1Slice(this, start, end)
699
+
700
+ case 'base64':
701
+ return base64Slice(this, start, end)
702
+
703
+ case 'ucs2':
704
+ case 'ucs-2':
705
+ case 'utf16le':
706
+ case 'utf-16le':
707
+ return utf16leSlice(this, start, end)
708
+
709
+ default:
710
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
711
+ encoding = (encoding + '').toLowerCase()
712
+ loweredCase = true
713
+ }
714
+ }
715
+ }
716
+
717
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
718
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
719
+ // reliably in a browserify context because there could be multiple different
720
+ // copies of the 'buffer' package in use. This method works even for Buffer
721
+ // instances that were created from another copy of the `buffer` package.
722
+ // See: https://github.com/feross/buffer/issues/154
723
+ Buffer.prototype._isBuffer = true
724
+
725
+ function swap (b, n, m) {
726
+ var i = b[n]
727
+ b[n] = b[m]
728
+ b[m] = i
729
+ }
730
+
731
+ Buffer.prototype.swap16 = function swap16 () {
732
+ var len = this.length
733
+ if (len % 2 !== 0) {
734
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
735
+ }
736
+ for (var i = 0; i < len; i += 2) {
737
+ swap(this, i, i + 1)
738
+ }
739
+ return this
740
+ }
741
+
742
+ Buffer.prototype.swap32 = function swap32 () {
743
+ var len = this.length
744
+ if (len % 4 !== 0) {
745
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
746
+ }
747
+ for (var i = 0; i < len; i += 4) {
748
+ swap(this, i, i + 3)
749
+ swap(this, i + 1, i + 2)
750
+ }
751
+ return this
752
+ }
753
+
754
+ Buffer.prototype.swap64 = function swap64 () {
755
+ var len = this.length
756
+ if (len % 8 !== 0) {
757
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
758
+ }
759
+ for (var i = 0; i < len; i += 8) {
760
+ swap(this, i, i + 7)
761
+ swap(this, i + 1, i + 6)
762
+ swap(this, i + 2, i + 5)
763
+ swap(this, i + 3, i + 4)
764
+ }
765
+ return this
766
+ }
767
+
768
+ Buffer.prototype.toString = function toString () {
769
+ var length = this.length
770
+ if (length === 0) return ''
771
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
772
+ return slowToString.apply(this, arguments)
773
+ }
774
+
775
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString
776
+
777
+ Buffer.prototype.equals = function equals (b) {
778
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
779
+ if (this === b) return true
780
+ return Buffer.compare(this, b) === 0
781
+ }
782
+
783
+ Buffer.prototype.inspect = function inspect () {
784
+ var str = ''
785
+ var max = exports.IS
786
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
787
+ if (this.length > max) str += ' ... '
788
+ return '<Buffer ' + str + '>'
789
+ }
790
+ if (customInspectSymbol) {
791
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
792
+ }
793
+
794
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
795
+ if (isInstance(target, Uint8Array)) {
796
+ target = Buffer.from(target, target.offset, target.byteLength)
797
+ }
798
+ if (!Buffer.isBuffer(target)) {
799
+ throw new TypeError(
800
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
801
+ 'Received type ' + (typeof target)
802
+ )
803
+ }
804
+
805
+ if (start === undefined) {
806
+ start = 0
807
+ }
808
+ if (end === undefined) {
809
+ end = target ? target.length : 0
810
+ }
811
+ if (thisStart === undefined) {
812
+ thisStart = 0
813
+ }
814
+ if (thisEnd === undefined) {
815
+ thisEnd = this.length
816
+ }
817
+
818
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
819
+ throw new RangeError('out of range index')
820
+ }
821
+
822
+ if (thisStart >= thisEnd && start >= end) {
823
+ return 0
824
+ }
825
+ if (thisStart >= thisEnd) {
826
+ return -1
827
+ }
828
+ if (start >= end) {
829
+ return 1
830
+ }
831
+
832
+ start >>>= 0
833
+ end >>>= 0
834
+ thisStart >>>= 0
835
+ thisEnd >>>= 0
836
+
837
+ if (this === target) return 0
838
+
839
+ var x = thisEnd - thisStart
840
+ var y = end - start
841
+ var len = Math.min(x, y)
842
+
843
+ var thisCopy = this.slice(thisStart, thisEnd)
844
+ var targetCopy = target.slice(start, end)
845
+
846
+ for (var i = 0; i < len; ++i) {
847
+ if (thisCopy[i] !== targetCopy[i]) {
848
+ x = thisCopy[i]
849
+ y = targetCopy[i]
850
+ break
851
+ }
852
+ }
853
+
854
+ if (x < y) return -1
855
+ if (y < x) return 1
856
+ return 0
857
+ }
858
+
859
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
860
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
861
+ //
862
+ // Arguments:
863
+ // - buffer - a Buffer to search
864
+ // - val - a string, Buffer, or number
865
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
866
+ // - encoding - an optional encoding, relevant is val is a string
867
+ // - dir - true for indexOf, false for lastIndexOf
868
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
869
+ // Empty buffer means no match
870
+ if (buffer.length === 0) return -1
871
+
872
+ // Normalize byteOffset
873
+ if (typeof byteOffset === 'string') {
874
+ encoding = byteOffset
875
+ byteOffset = 0
876
+ } else if (byteOffset > 0x7fffffff) {
877
+ byteOffset = 0x7fffffff
878
+ } else if (byteOffset < -0x80000000) {
879
+ byteOffset = -0x80000000
880
+ }
881
+ byteOffset = +byteOffset // Coerce to Number.
882
+ if (numberIsNaN(byteOffset)) {
883
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
884
+ byteOffset = dir ? 0 : (buffer.length - 1)
885
+ }
886
+
887
+ // Normalize byteOffset: negative offsets start from the end of the buffer
888
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset
889
+ if (byteOffset >= buffer.length) {
890
+ if (dir) return -1
891
+ else byteOffset = buffer.length - 1
892
+ } else if (byteOffset < 0) {
893
+ if (dir) byteOffset = 0
894
+ else return -1
895
+ }
896
+
897
+ // Normalize val
898
+ if (typeof val === 'string') {
899
+ val = Buffer.from(val, encoding)
900
+ }
901
+
902
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
903
+ if (Buffer.isBuffer(val)) {
904
+ // Special case: looking for empty string/buffer always fails
905
+ if (val.length === 0) {
906
+ return -1
907
+ }
908
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
909
+ } else if (typeof val === 'number') {
910
+ val = val & 0xFF // Search for a byte value [0-255]
911
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
912
+ if (dir) {
913
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
914
+ } else {
915
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
916
+ }
917
+ }
918
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
919
+ }
920
+
921
+ throw new TypeError('val must be string, number or Buffer')
922
+ }
923
+
924
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
925
+ var indexSize = 1
926
+ var arrLength = arr.length
927
+ var valLength = val.length
928
+
929
+ if (encoding !== undefined) {
930
+ encoding = String(encoding).toLowerCase()
931
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
932
+ encoding === 'utf16le' || encoding === 'utf-16le') {
933
+ if (arr.length < 2 || val.length < 2) {
934
+ return -1
935
+ }
936
+ indexSize = 2
937
+ arrLength /= 2
938
+ valLength /= 2
939
+ byteOffset /= 2
940
+ }
941
+ }
942
+
943
+ function read (buf, i) {
944
+ if (indexSize === 1) {
945
+ return buf[i]
946
+ } else {
947
+ return buf.readUInt16BE(i * indexSize)
948
+ }
949
+ }
950
+
951
+ var i
952
+ if (dir) {
953
+ var foundIndex = -1
954
+ for (i = byteOffset; i < arrLength; i++) {
955
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
956
+ if (foundIndex === -1) foundIndex = i
957
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
958
+ } else {
959
+ if (foundIndex !== -1) i -= i - foundIndex
960
+ foundIndex = -1
961
+ }
962
+ }
963
+ } else {
964
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
965
+ for (i = byteOffset; i >= 0; i--) {
966
+ var found = true
967
+ for (var j = 0; j < valLength; j++) {
968
+ if (read(arr, i + j) !== read(val, j)) {
969
+ found = false
970
+ break
971
+ }
972
+ }
973
+ if (found) return i
974
+ }
975
+ }
976
+
977
+ return -1
978
+ }
979
+
980
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
981
+ return this.indexOf(val, byteOffset, encoding) !== -1
982
+ }
983
+
984
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
985
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
986
+ }
987
+
988
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
989
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
990
+ }
991
+
992
+ function hexWrite (buf, string, offset, length) {
993
+ offset = Number(offset) || 0
994
+ var remaining = buf.length - offset
995
+ if (!length) {
996
+ length = remaining
997
+ } else {
998
+ length = Number(length)
999
+ if (length > remaining) {
1000
+ length = remaining
1001
+ }
1002
+ }
1003
+
1004
+ var strLen = string.length
1005
+
1006
+ if (length > strLen / 2) {
1007
+ length = strLen / 2
1008
+ }
1009
+ for (var i = 0; i < length; ++i) {
1010
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
1011
+ if (numberIsNaN(parsed)) return i
1012
+ buf[offset + i] = parsed
1013
+ }
1014
+ return i
1015
+ }
1016
+
1017
+ function utf8Write (buf, string, offset, length) {
1018
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1019
+ }
1020
+
1021
+ function asciiWrite (buf, string, offset, length) {
1022
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
1023
+ }
1024
+
1025
+ function base64Write (buf, string, offset, length) {
1026
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
1027
+ }
1028
+
1029
+ function ucs2Write (buf, string, offset, length) {
1030
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1031
+ }
1032
+
1033
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
1034
+ // Buffer#write(string)
1035
+ if (offset === undefined) {
1036
+ encoding = 'utf8'
1037
+ length = this.length
1038
+ offset = 0
1039
+ // Buffer#write(string, encoding)
1040
+ } else if (length === undefined && typeof offset === 'string') {
1041
+ encoding = offset
1042
+ length = this.length
1043
+ offset = 0
1044
+ // Buffer#write(string, offset[, length][, encoding])
1045
+ } else if (isFinite(offset)) {
1046
+ offset = offset >>> 0
1047
+ if (isFinite(length)) {
1048
+ length = length >>> 0
1049
+ if (encoding === undefined) encoding = 'utf8'
1050
+ } else {
1051
+ encoding = length
1052
+ length = undefined
1053
+ }
1054
+ } else {
1055
+ throw new Error(
1056
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1057
+ )
1058
+ }
1059
+
1060
+ var remaining = this.length - offset
1061
+ if (length === undefined || length > remaining) length = remaining
1062
+
1063
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1064
+ throw new RangeError('Attempt to write outside buffer bounds')
1065
+ }
1066
+
1067
+ if (!encoding) encoding = 'utf8'
1068
+
1069
+ var loweredCase = false
1070
+ for (;;) {
1071
+ switch (encoding) {
1072
+ case 'hex':
1073
+ return hexWrite(this, string, offset, length)
1074
+
1075
+ case 'utf8':
1076
+ case 'utf-8':
1077
+ return utf8Write(this, string, offset, length)
1078
+
1079
+ case 'ascii':
1080
+ case 'latin1':
1081
+ case 'binary':
1082
+ return asciiWrite(this, string, offset, length)
1083
+
1084
+ case 'base64':
1085
+ // Warning: maxLength not taken into account in base64Write
1086
+ return base64Write(this, string, offset, length)
1087
+
1088
+ case 'ucs2':
1089
+ case 'ucs-2':
1090
+ case 'utf16le':
1091
+ case 'utf-16le':
1092
+ return ucs2Write(this, string, offset, length)
1093
+
1094
+ default:
1095
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1096
+ encoding = ('' + encoding).toLowerCase()
1097
+ loweredCase = true
1098
+ }
1099
+ }
1100
+ }
1101
+
1102
+ Buffer.prototype.toJSON = function toJSON () {
1103
+ return {
1104
+ type: 'Buffer',
1105
+ data: Array.prototype.slice.call(this._arr || this, 0)
1106
+ }
1107
+ }
1108
+
1109
+ function base64Slice (buf, start, end) {
1110
+ if (start === 0 && end === buf.length) {
1111
+ return base64.fromByteArray(buf)
1112
+ } else {
1113
+ return base64.fromByteArray(buf.slice(start, end))
1114
+ }
1115
+ }
1116
+
1117
+ function utf8Slice (buf, start, end) {
1118
+ end = Math.min(buf.length, end)
1119
+ var res = []
1120
+
1121
+ var i = start
1122
+ while (i < end) {
1123
+ var firstByte = buf[i]
1124
+ var codePoint = null
1125
+ var bytesPerSequence = (firstByte > 0xEF)
1126
+ ? 4
1127
+ : (firstByte > 0xDF)
1128
+ ? 3
1129
+ : (firstByte > 0xBF)
1130
+ ? 2
1131
+ : 1
1132
+
1133
+ if (i + bytesPerSequence <= end) {
1134
+ var secondByte, thirdByte, fourthByte, tempCodePoint
1135
+
1136
+ switch (bytesPerSequence) {
1137
+ case 1:
1138
+ if (firstByte < 0x80) {
1139
+ codePoint = firstByte
1140
+ }
1141
+ break
1142
+ case 2:
1143
+ secondByte = buf[i + 1]
1144
+ if ((secondByte & 0xC0) === 0x80) {
1145
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1146
+ if (tempCodePoint > 0x7F) {
1147
+ codePoint = tempCodePoint
1148
+ }
1149
+ }
1150
+ break
1151
+ case 3:
1152
+ secondByte = buf[i + 1]
1153
+ thirdByte = buf[i + 2]
1154
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1155
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1156
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1157
+ codePoint = tempCodePoint
1158
+ }
1159
+ }
1160
+ break
1161
+ case 4:
1162
+ secondByte = buf[i + 1]
1163
+ thirdByte = buf[i + 2]
1164
+ fourthByte = buf[i + 3]
1165
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1166
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1167
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1168
+ codePoint = tempCodePoint
1169
+ }
1170
+ }
1171
+ }
1172
+ }
1173
+
1174
+ if (codePoint === null) {
1175
+ // we did not generate a valid codePoint so insert a
1176
+ // replacement char (U+FFFD) and advance only 1 byte
1177
+ codePoint = 0xFFFD
1178
+ bytesPerSequence = 1
1179
+ } else if (codePoint > 0xFFFF) {
1180
+ // encode to utf16 (surrogate pair dance)
1181
+ codePoint -= 0x10000
1182
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1183
+ codePoint = 0xDC00 | codePoint & 0x3FF
1184
+ }
1185
+
1186
+ res.push(codePoint)
1187
+ i += bytesPerSequence
1188
+ }
1189
+
1190
+ return decodeCodePointsArray(res)
1191
+ }
1192
+
1193
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1194
+ // the lowest limit is Chrome, with 0x10000 args.
1195
+ // We go 1 magnitude less, for safety
1196
+ var MAX_ARGUMENTS_LENGTH = 0x1000
1197
+
1198
+ function decodeCodePointsArray (codePoints) {
1199
+ var len = codePoints.length
1200
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1201
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1202
+ }
1203
+
1204
+ // Decode in chunks to avoid "call stack size exceeded".
1205
+ var res = ''
1206
+ var i = 0
1207
+ while (i < len) {
1208
+ res += String.fromCharCode.apply(
1209
+ String,
1210
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1211
+ )
1212
+ }
1213
+ return res
1214
+ }
1215
+
1216
+ function asciiSlice (buf, start, end) {
1217
+ var ret = ''
1218
+ end = Math.min(buf.length, end)
1219
+
1220
+ for (var i = start; i < end; ++i) {
1221
+ ret += String.fromCharCode(buf[i] & 0x7F)
1222
+ }
1223
+ return ret
1224
+ }
1225
+
1226
+ function latin1Slice (buf, start, end) {
1227
+ var ret = ''
1228
+ end = Math.min(buf.length, end)
1229
+
1230
+ for (var i = start; i < end; ++i) {
1231
+ ret += String.fromCharCode(buf[i])
1232
+ }
1233
+ return ret
1234
+ }
1235
+
1236
+ function hexSlice (buf, start, end) {
1237
+ var len = buf.length
1238
+
1239
+ if (!start || start < 0) start = 0
1240
+ if (!end || end < 0 || end > len) end = len
1241
+
1242
+ var out = ''
1243
+ for (var i = start; i < end; ++i) {
1244
+ out += hexSliceLookupTable[buf[i]]
1245
+ }
1246
+ return out
1247
+ }
1248
+
1249
+ function utf16leSlice (buf, start, end) {
1250
+ var bytes = buf.slice(start, end)
1251
+ var res = ''
1252
+ // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
1253
+ for (var i = 0; i < bytes.length - 1; i += 2) {
1254
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
1255
+ }
1256
+ return res
1257
+ }
1258
+
1259
+ Buffer.prototype.slice = function slice (start, end) {
1260
+ var len = this.length
1261
+ start = ~~start
1262
+ end = end === undefined ? len : ~~end
1263
+
1264
+ if (start < 0) {
1265
+ start += len
1266
+ if (start < 0) start = 0
1267
+ } else if (start > len) {
1268
+ start = len
1269
+ }
1270
+
1271
+ if (end < 0) {
1272
+ end += len
1273
+ if (end < 0) end = 0
1274
+ } else if (end > len) {
1275
+ end = len
1276
+ }
1277
+
1278
+ if (end < start) end = start
1279
+
1280
+ var newBuf = this.subarray(start, end)
1281
+ // Return an augmented `Uint8Array` instance
1282
+ Object.setPrototypeOf(newBuf, Buffer.prototype)
1283
+
1284
+ return newBuf
1285
+ }
1286
+
1287
+ /*
1288
+ * Need to make sure that buffer isn't trying to write out of bounds.
1289
+ */
1290
+ function checkOffset (offset, ext, length) {
1291
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1292
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1293
+ }
1294
+
1295
+ Buffer.prototype.readUintLE =
1296
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1297
+ offset = offset >>> 0
1298
+ byteLength = byteLength >>> 0
1299
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
1300
+
1301
+ var val = this[offset]
1302
+ var mul = 1
1303
+ var i = 0
1304
+ while (++i < byteLength && (mul *= 0x100)) {
1305
+ val += this[offset + i] * mul
1306
+ }
1307
+
1308
+ return val
1309
+ }
1310
+
1311
+ Buffer.prototype.readUintBE =
1312
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1313
+ offset = offset >>> 0
1314
+ byteLength = byteLength >>> 0
1315
+ if (!noAssert) {
1316
+ checkOffset(offset, byteLength, this.length)
1317
+ }
1318
+
1319
+ var val = this[offset + --byteLength]
1320
+ var mul = 1
1321
+ while (byteLength > 0 && (mul *= 0x100)) {
1322
+ val += this[offset + --byteLength] * mul
1323
+ }
1324
+
1325
+ return val
1326
+ }
1327
+
1328
+ Buffer.prototype.readUint8 =
1329
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1330
+ offset = offset >>> 0
1331
+ if (!noAssert) checkOffset(offset, 1, this.length)
1332
+ return this[offset]
1333
+ }
1334
+
1335
+ Buffer.prototype.readUint16LE =
1336
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1337
+ offset = offset >>> 0
1338
+ if (!noAssert) checkOffset(offset, 2, this.length)
1339
+ return this[offset] | (this[offset + 1] << 8)
1340
+ }
1341
+
1342
+ Buffer.prototype.readUint16BE =
1343
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1344
+ offset = offset >>> 0
1345
+ if (!noAssert) checkOffset(offset, 2, this.length)
1346
+ return (this[offset] << 8) | this[offset + 1]
1347
+ }
1348
+
1349
+ Buffer.prototype.readUint32LE =
1350
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1351
+ offset = offset >>> 0
1352
+ if (!noAssert) checkOffset(offset, 4, this.length)
1353
+
1354
+ return ((this[offset]) |
1355
+ (this[offset + 1] << 8) |
1356
+ (this[offset + 2] << 16)) +
1357
+ (this[offset + 3] * 0x1000000)
1358
+ }
1359
+
1360
+ Buffer.prototype.readUint32BE =
1361
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1362
+ offset = offset >>> 0
1363
+ if (!noAssert) checkOffset(offset, 4, this.length)
1364
+
1365
+ return (this[offset] * 0x1000000) +
1366
+ ((this[offset + 1] << 16) |
1367
+ (this[offset + 2] << 8) |
1368
+ this[offset + 3])
1369
+ }
1370
+
1371
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1372
+ offset = offset >>> 0
1373
+ byteLength = byteLength >>> 0
1374
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
1375
+
1376
+ var val = this[offset]
1377
+ var mul = 1
1378
+ var i = 0
1379
+ while (++i < byteLength && (mul *= 0x100)) {
1380
+ val += this[offset + i] * mul
1381
+ }
1382
+ mul *= 0x80
1383
+
1384
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1385
+
1386
+ return val
1387
+ }
1388
+
1389
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1390
+ offset = offset >>> 0
1391
+ byteLength = byteLength >>> 0
1392
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
1393
+
1394
+ var i = byteLength
1395
+ var mul = 1
1396
+ var val = this[offset + --i]
1397
+ while (i > 0 && (mul *= 0x100)) {
1398
+ val += this[offset + --i] * mul
1399
+ }
1400
+ mul *= 0x80
1401
+
1402
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1403
+
1404
+ return val
1405
+ }
1406
+
1407
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1408
+ offset = offset >>> 0
1409
+ if (!noAssert) checkOffset(offset, 1, this.length)
1410
+ if (!(this[offset] & 0x80)) return (this[offset])
1411
+ return ((0xff - this[offset] + 1) * -1)
1412
+ }
1413
+
1414
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1415
+ offset = offset >>> 0
1416
+ if (!noAssert) checkOffset(offset, 2, this.length)
1417
+ var val = this[offset] | (this[offset + 1] << 8)
1418
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
1419
+ }
1420
+
1421
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1422
+ offset = offset >>> 0
1423
+ if (!noAssert) checkOffset(offset, 2, this.length)
1424
+ var val = this[offset + 1] | (this[offset] << 8)
1425
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
1426
+ }
1427
+
1428
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1429
+ offset = offset >>> 0
1430
+ if (!noAssert) checkOffset(offset, 4, this.length)
1431
+
1432
+ return (this[offset]) |
1433
+ (this[offset + 1] << 8) |
1434
+ (this[offset + 2] << 16) |
1435
+ (this[offset + 3] << 24)
1436
+ }
1437
+
1438
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1439
+ offset = offset >>> 0
1440
+ if (!noAssert) checkOffset(offset, 4, this.length)
1441
+
1442
+ return (this[offset] << 24) |
1443
+ (this[offset + 1] << 16) |
1444
+ (this[offset + 2] << 8) |
1445
+ (this[offset + 3])
1446
+ }
1447
+
1448
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1449
+ offset = offset >>> 0
1450
+ if (!noAssert) checkOffset(offset, 4, this.length)
1451
+ return ieee754.read(this, offset, true, 23, 4)
1452
+ }
1453
+
1454
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1455
+ offset = offset >>> 0
1456
+ if (!noAssert) checkOffset(offset, 4, this.length)
1457
+ return ieee754.read(this, offset, false, 23, 4)
1458
+ }
1459
+
1460
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1461
+ offset = offset >>> 0
1462
+ if (!noAssert) checkOffset(offset, 8, this.length)
1463
+ return ieee754.read(this, offset, true, 52, 8)
1464
+ }
1465
+
1466
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1467
+ offset = offset >>> 0
1468
+ if (!noAssert) checkOffset(offset, 8, this.length)
1469
+ return ieee754.read(this, offset, false, 52, 8)
1470
+ }
1471
+
1472
+ function checkInt (buf, value, offset, ext, max, min) {
1473
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1474
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1475
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
1476
+ }
1477
+
1478
+ Buffer.prototype.writeUintLE =
1479
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1480
+ value = +value
1481
+ offset = offset >>> 0
1482
+ byteLength = byteLength >>> 0
1483
+ if (!noAssert) {
1484
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
1485
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
1486
+ }
1487
+
1488
+ var mul = 1
1489
+ var i = 0
1490
+ this[offset] = value & 0xFF
1491
+ while (++i < byteLength && (mul *= 0x100)) {
1492
+ this[offset + i] = (value / mul) & 0xFF
1493
+ }
1494
+
1495
+ return offset + byteLength
1496
+ }
1497
+
1498
+ Buffer.prototype.writeUintBE =
1499
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1500
+ value = +value
1501
+ offset = offset >>> 0
1502
+ byteLength = byteLength >>> 0
1503
+ if (!noAssert) {
1504
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1
1505
+ checkInt(this, value, offset, byteLength, maxBytes, 0)
1506
+ }
1507
+
1508
+ var i = byteLength - 1
1509
+ var mul = 1
1510
+ this[offset + i] = value & 0xFF
1511
+ while (--i >= 0 && (mul *= 0x100)) {
1512
+ this[offset + i] = (value / mul) & 0xFF
1513
+ }
1514
+
1515
+ return offset + byteLength
1516
+ }
1517
+
1518
+ Buffer.prototype.writeUint8 =
1519
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1520
+ value = +value
1521
+ offset = offset >>> 0
1522
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1523
+ this[offset] = (value & 0xff)
1524
+ return offset + 1
1525
+ }
1526
+
1527
+ Buffer.prototype.writeUint16LE =
1528
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1529
+ value = +value
1530
+ offset = offset >>> 0
1531
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1532
+ this[offset] = (value & 0xff)
1533
+ this[offset + 1] = (value >>> 8)
1534
+ return offset + 2
1535
+ }
1536
+
1537
+ Buffer.prototype.writeUint16BE =
1538
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1539
+ value = +value
1540
+ offset = offset >>> 0
1541
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1542
+ this[offset] = (value >>> 8)
1543
+ this[offset + 1] = (value & 0xff)
1544
+ return offset + 2
1545
+ }
1546
+
1547
+ Buffer.prototype.writeUint32LE =
1548
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1549
+ value = +value
1550
+ offset = offset >>> 0
1551
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1552
+ this[offset + 3] = (value >>> 24)
1553
+ this[offset + 2] = (value >>> 16)
1554
+ this[offset + 1] = (value >>> 8)
1555
+ this[offset] = (value & 0xff)
1556
+ return offset + 4
1557
+ }
1558
+
1559
+ Buffer.prototype.writeUint32BE =
1560
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1561
+ value = +value
1562
+ offset = offset >>> 0
1563
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1564
+ this[offset] = (value >>> 24)
1565
+ this[offset + 1] = (value >>> 16)
1566
+ this[offset + 2] = (value >>> 8)
1567
+ this[offset + 3] = (value & 0xff)
1568
+ return offset + 4
1569
+ }
1570
+
1571
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1572
+ value = +value
1573
+ offset = offset >>> 0
1574
+ if (!noAssert) {
1575
+ var limit = Math.pow(2, (8 * byteLength) - 1)
1576
+
1577
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
1578
+ }
1579
+
1580
+ var i = 0
1581
+ var mul = 1
1582
+ var sub = 0
1583
+ this[offset] = value & 0xFF
1584
+ while (++i < byteLength && (mul *= 0x100)) {
1585
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1586
+ sub = 1
1587
+ }
1588
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1589
+ }
1590
+
1591
+ return offset + byteLength
1592
+ }
1593
+
1594
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1595
+ value = +value
1596
+ offset = offset >>> 0
1597
+ if (!noAssert) {
1598
+ var limit = Math.pow(2, (8 * byteLength) - 1)
1599
+
1600
+ checkInt(this, value, offset, byteLength, limit - 1, -limit)
1601
+ }
1602
+
1603
+ var i = byteLength - 1
1604
+ var mul = 1
1605
+ var sub = 0
1606
+ this[offset + i] = value & 0xFF
1607
+ while (--i >= 0 && (mul *= 0x100)) {
1608
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1609
+ sub = 1
1610
+ }
1611
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1612
+ }
1613
+
1614
+ return offset + byteLength
1615
+ }
1616
+
1617
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1618
+ value = +value
1619
+ offset = offset >>> 0
1620
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1621
+ if (value < 0) value = 0xff + value + 1
1622
+ this[offset] = (value & 0xff)
1623
+ return offset + 1
1624
+ }
1625
+
1626
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1627
+ value = +value
1628
+ offset = offset >>> 0
1629
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1630
+ this[offset] = (value & 0xff)
1631
+ this[offset + 1] = (value >>> 8)
1632
+ return offset + 2
1633
+ }
1634
+
1635
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1636
+ value = +value
1637
+ offset = offset >>> 0
1638
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1639
+ this[offset] = (value >>> 8)
1640
+ this[offset + 1] = (value & 0xff)
1641
+ return offset + 2
1642
+ }
1643
+
1644
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1645
+ value = +value
1646
+ offset = offset >>> 0
1647
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1648
+ this[offset] = (value & 0xff)
1649
+ this[offset + 1] = (value >>> 8)
1650
+ this[offset + 2] = (value >>> 16)
1651
+ this[offset + 3] = (value >>> 24)
1652
+ return offset + 4
1653
+ }
1654
+
1655
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1656
+ value = +value
1657
+ offset = offset >>> 0
1658
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1659
+ if (value < 0) value = 0xffffffff + value + 1
1660
+ this[offset] = (value >>> 24)
1661
+ this[offset + 1] = (value >>> 16)
1662
+ this[offset + 2] = (value >>> 8)
1663
+ this[offset + 3] = (value & 0xff)
1664
+ return offset + 4
1665
+ }
1666
+
1667
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
1668
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
1669
+ if (offset < 0) throw new RangeError('Index out of range')
1670
+ }
1671
+
1672
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
1673
+ value = +value
1674
+ offset = offset >>> 0
1675
+ if (!noAssert) {
1676
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1677
+ }
1678
+ ieee754.write(buf, value, offset, littleEndian, 23, 4)
1679
+ return offset + 4
1680
+ }
1681
+
1682
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1683
+ return writeFloat(this, value, offset, true, noAssert)
1684
+ }
1685
+
1686
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1687
+ return writeFloat(this, value, offset, false, noAssert)
1688
+ }
1689
+
1690
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
1691
+ value = +value
1692
+ offset = offset >>> 0
1693
+ if (!noAssert) {
1694
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1695
+ }
1696
+ ieee754.write(buf, value, offset, littleEndian, 52, 8)
1697
+ return offset + 8
1698
+ }
1699
+
1700
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1701
+ return writeDouble(this, value, offset, true, noAssert)
1702
+ }
1703
+
1704
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1705
+ return writeDouble(this, value, offset, false, noAssert)
1706
+ }
1707
+
1708
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1709
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1710
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
1711
+ if (!start) start = 0
1712
+ if (!end && end !== 0) end = this.length
1713
+ if (targetStart >= target.length) targetStart = target.length
1714
+ if (!targetStart) targetStart = 0
1715
+ if (end > 0 && end < start) end = start
1716
+
1717
+ // Copy 0 bytes; we're done
1718
+ if (end === start) return 0
1719
+ if (target.length === 0 || this.length === 0) return 0
1720
+
1721
+ // Fatal error conditions
1722
+ if (targetStart < 0) {
1723
+ throw new RangeError('targetStart out of bounds')
1724
+ }
1725
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
1726
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
1727
+
1728
+ // Are we oob?
1729
+ if (end > this.length) end = this.length
1730
+ if (target.length - targetStart < end - start) {
1731
+ end = target.length - targetStart + start
1732
+ }
1733
+
1734
+ var len = end - start
1735
+
1736
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
1737
+ // Use built-in when available, missing from IE11
1738
+ this.copyWithin(targetStart, start, end)
1739
+ } else {
1740
+ Uint8Array.prototype.set.call(
1741
+ target,
1742
+ this.subarray(start, end),
1743
+ targetStart
1744
+ )
1745
+ }
1746
+
1747
+ return len
1748
+ }
1749
+
1750
+ // Usage:
1751
+ // buffer.fill(number[, offset[, end]])
1752
+ // buffer.fill(buffer[, offset[, end]])
1753
+ // buffer.fill(string[, offset[, end]][, encoding])
1754
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
1755
+ // Handle string cases:
1756
+ if (typeof val === 'string') {
1757
+ if (typeof start === 'string') {
1758
+ encoding = start
1759
+ start = 0
1760
+ end = this.length
1761
+ } else if (typeof end === 'string') {
1762
+ encoding = end
1763
+ end = this.length
1764
+ }
1765
+ if (encoding !== undefined && typeof encoding !== 'string') {
1766
+ throw new TypeError('encoding must be a string')
1767
+ }
1768
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1769
+ throw new TypeError('Unknown encoding: ' + encoding)
1770
+ }
1771
+ if (val.length === 1) {
1772
+ var code = val.charCodeAt(0)
1773
+ if ((encoding === 'utf8' && code < 128) ||
1774
+ encoding === 'latin1') {
1775
+ // Fast path: If `val` fits into a single byte, use that numeric value.
1776
+ val = code
1777
+ }
1778
+ }
1779
+ } else if (typeof val === 'number') {
1780
+ val = val & 255
1781
+ } else if (typeof val === 'boolean') {
1782
+ val = Number(val)
1783
+ }
1784
+
1785
+ // Invalid ranges are not set to a default, so can range check early.
1786
+ if (start < 0 || this.length < start || this.length < end) {
1787
+ throw new RangeError('Out of range index')
1788
+ }
1789
+
1790
+ if (end <= start) {
1791
+ return this
1792
+ }
1793
+
1794
+ start = start >>> 0
1795
+ end = end === undefined ? this.length : end >>> 0
1796
+
1797
+ if (!val) val = 0
1798
+
1799
+ var i
1800
+ if (typeof val === 'number') {
1801
+ for (i = start; i < end; ++i) {
1802
+ this[i] = val
1803
+ }
1804
+ } else {
1805
+ var bytes = Buffer.isBuffer(val)
1806
+ ? val
1807
+ : Buffer.from(val, encoding)
1808
+ var len = bytes.length
1809
+ if (len === 0) {
1810
+ throw new TypeError('The value "' + val +
1811
+ '" is invalid for argument "value"')
1812
+ }
1813
+ for (i = 0; i < end - start; ++i) {
1814
+ this[i + start] = bytes[i % len]
1815
+ }
1816
+ }
1817
+
1818
+ return this
1819
+ }
1820
+
1821
+ // HELPER FUNCTIONS
1822
+ // ================
1823
+
1824
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
1825
+
1826
+ function base64clean (str) {
1827
+ // Node takes equal signs as end of the Base64 encoding
1828
+ str = str.split('=')[0]
1829
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
1830
+ str = str.trim().replace(INVALID_BASE64_RE, '')
1831
+ // Node converts strings with length < 2 to ''
1832
+ if (str.length < 2) return ''
1833
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1834
+ while (str.length % 4 !== 0) {
1835
+ str = str + '='
1836
+ }
1837
+ return str
1838
+ }
1839
+
1840
+ function utf8ToBytes (string, units) {
1841
+ units = units || Infinity
1842
+ var codePoint
1843
+ var length = string.length
1844
+ var leadSurrogate = null
1845
+ var bytes = []
1846
+
1847
+ for (var i = 0; i < length; ++i) {
1848
+ codePoint = string.charCodeAt(i)
1849
+
1850
+ // is surrogate component
1851
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
1852
+ // last char was a lead
1853
+ if (!leadSurrogate) {
1854
+ // no lead yet
1855
+ if (codePoint > 0xDBFF) {
1856
+ // unexpected trail
1857
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1858
+ continue
1859
+ } else if (i + 1 === length) {
1860
+ // unpaired lead
1861
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1862
+ continue
1863
+ }
1864
+
1865
+ // valid lead
1866
+ leadSurrogate = codePoint
1867
+
1868
+ continue
1869
+ }
1870
+
1871
+ // 2 leads in a row
1872
+ if (codePoint < 0xDC00) {
1873
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1874
+ leadSurrogate = codePoint
1875
+ continue
1876
+ }
1877
+
1878
+ // valid surrogate pair
1879
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
1880
+ } else if (leadSurrogate) {
1881
+ // valid bmp char, but last char was a lead
1882
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1883
+ }
1884
+
1885
+ leadSurrogate = null
1886
+
1887
+ // encode utf8
1888
+ if (codePoint < 0x80) {
1889
+ if ((units -= 1) < 0) break
1890
+ bytes.push(codePoint)
1891
+ } else if (codePoint < 0x800) {
1892
+ if ((units -= 2) < 0) break
1893
+ bytes.push(
1894
+ codePoint >> 0x6 | 0xC0,
1895
+ codePoint & 0x3F | 0x80
1896
+ )
1897
+ } else if (codePoint < 0x10000) {
1898
+ if ((units -= 3) < 0) break
1899
+ bytes.push(
1900
+ codePoint >> 0xC | 0xE0,
1901
+ codePoint >> 0x6 & 0x3F | 0x80,
1902
+ codePoint & 0x3F | 0x80
1903
+ )
1904
+ } else if (codePoint < 0x110000) {
1905
+ if ((units -= 4) < 0) break
1906
+ bytes.push(
1907
+ codePoint >> 0x12 | 0xF0,
1908
+ codePoint >> 0xC & 0x3F | 0x80,
1909
+ codePoint >> 0x6 & 0x3F | 0x80,
1910
+ codePoint & 0x3F | 0x80
1911
+ )
1912
+ } else {
1913
+ throw new Error('Invalid code point')
1914
+ }
1915
+ }
1916
+
1917
+ return bytes
1918
+ }
1919
+
1920
+ function asciiToBytes (str) {
1921
+ var byteArray = []
1922
+ for (var i = 0; i < str.length; ++i) {
1923
+ // Node's code seems to be doing this and not & 0x7F..
1924
+ byteArray.push(str.charCodeAt(i) & 0xFF)
1925
+ }
1926
+ return byteArray
1927
+ }
1928
+
1929
+ function utf16leToBytes (str, units) {
1930
+ var c, hi, lo
1931
+ var byteArray = []
1932
+ for (var i = 0; i < str.length; ++i) {
1933
+ if ((units -= 2) < 0) break
1934
+
1935
+ c = str.charCodeAt(i)
1936
+ hi = c >> 8
1937
+ lo = c % 256
1938
+ byteArray.push(lo)
1939
+ byteArray.push(hi)
1940
+ }
1941
+
1942
+ return byteArray
1943
+ }
1944
+
1945
+ function base64ToBytes (str) {
1946
+ return base64.toByteArray(base64clean(str))
1947
+ }
1948
+
1949
+ function blitBuffer (src, dst, offset, length) {
1950
+ for (var i = 0; i < length; ++i) {
1951
+ if ((i + offset >= dst.length) || (i >= src.length)) break
1952
+ dst[i + offset] = src[i]
1953
+ }
1954
+ return i
1955
+ }
1956
+
1957
+ // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
1958
+ // the `instanceof` check but they should be treated as of that type.
1959
+ // See: https://github.com/feross/buffer/issues/166
1960
+ function isInstance (obj, type) {
1961
+ return obj instanceof type ||
1962
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
1963
+ obj.constructor.name === type.name)
1964
+ }
1965
+ function numberIsNaN (obj) {
1966
+ // For IE11 support
1967
+ return obj !== obj // eslint-disable-line no-self-compare
1968
+ }
1969
+
1970
+ // Create lookup table for `toString('hex')`
1971
+ // See: https://github.com/feross/buffer/issues/219
1972
+ var hexSliceLookupTable = (function () {
1973
+ var alphabet = '0123456789abcdef'
1974
+ var table = new Array(256)
1975
+ for (var i = 0; i < 16; ++i) {
1976
+ var i16 = i * 16
1977
+ for (var j = 0; j < 16; ++j) {
1978
+ table[i16 + j] = alphabet[i] + alphabet[j]
1979
+ }
1980
+ }
1981
+ return table
1982
+ })()
1983
+
1984
+
1985
+ /***/ }),
1986
+
1987
+ /***/ 55801:
1988
+ /***/ ((__unused_webpack_module, exports) => {
1989
+
1990
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
1991
+ exports.read = function (buffer, offset, isLE, mLen, nBytes) {
1992
+ var e, m
1993
+ var eLen = (nBytes * 8) - mLen - 1
1994
+ var eMax = (1 << eLen) - 1
1995
+ var eBias = eMax >> 1
1996
+ var nBits = -7
1997
+ var i = isLE ? (nBytes - 1) : 0
1998
+ var d = isLE ? -1 : 1
1999
+ var s = buffer[offset + i]
2000
+
2001
+ i += d
2002
+
2003
+ e = s & ((1 << (-nBits)) - 1)
2004
+ s >>= (-nBits)
2005
+ nBits += eLen
2006
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
2007
+
2008
+ m = e & ((1 << (-nBits)) - 1)
2009
+ e >>= (-nBits)
2010
+ nBits += mLen
2011
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
2012
+
2013
+ if (e === 0) {
2014
+ e = 1 - eBias
2015
+ } else if (e === eMax) {
2016
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
2017
+ } else {
2018
+ m = m + Math.pow(2, mLen)
2019
+ e = e - eBias
2020
+ }
2021
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
2022
+ }
2023
+
2024
+ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2025
+ var e, m, c
2026
+ var eLen = (nBytes * 8) - mLen - 1
2027
+ var eMax = (1 << eLen) - 1
2028
+ var eBias = eMax >> 1
2029
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
2030
+ var i = isLE ? 0 : (nBytes - 1)
2031
+ var d = isLE ? 1 : -1
2032
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
2033
+
2034
+ value = Math.abs(value)
2035
+
2036
+ if (isNaN(value) || value === Infinity) {
2037
+ m = isNaN(value) ? 1 : 0
2038
+ e = eMax
2039
+ } else {
2040
+ e = Math.floor(Math.log(value) / Math.LN2)
2041
+ if (value * (c = Math.pow(2, -e)) < 1) {
2042
+ e--
2043
+ c *= 2
2044
+ }
2045
+ if (e + eBias >= 1) {
2046
+ value += rt / c
2047
+ } else {
2048
+ value += rt * Math.pow(2, 1 - eBias)
2049
+ }
2050
+ if (value * c >= 2) {
2051
+ e++
2052
+ c /= 2
2053
+ }
2054
+
2055
+ if (e + eBias >= eMax) {
2056
+ m = 0
2057
+ e = eMax
2058
+ } else if (e + eBias >= 1) {
2059
+ m = ((value * c) - 1) * Math.pow(2, mLen)
2060
+ e = e + eBias
2061
+ } else {
2062
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
2063
+ e = 0
2064
+ }
2065
+ }
2066
+
2067
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
2068
+
2069
+ e = (e << mLen) | m
2070
+ eLen += mLen
2071
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
2072
+
2073
+ buffer[offset + i - d] |= s * 128
2074
+ }
2075
+
2076
+
2077
+ /***/ })
2078
+
2079
+ }]);