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