@leofcoin/peernet 1.1.2 → 1.1.3

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.
@@ -1,6 +1,4 @@
1
- import { L as LittlePubSub, c as commonjsGlobal, r as require$$3, i as inherits_browserExports } from './peernet-5b33f983.js';
2
- import require$$0 from 'buffer';
3
- import require$$0$1 from 'events';
1
+ import { L as LittlePubSub, c as commonjsGlobal, r as require$$3, i as inherits_browserExports } from './peernet-7b231fd6.js';
4
2
  import './value-157ab062.js';
5
3
 
6
4
  var clientApi = _pubsub => {
@@ -977,12 +975,2361 @@ var safeBuffer = {
977
975
  set exports(v){ safeBufferExports = v; },
978
976
  };
979
977
 
978
+ var buffer = {};
979
+
980
+ var base64Js = {};
981
+
982
+ base64Js.byteLength = byteLength;
983
+ base64Js.toByteArray = toByteArray;
984
+ base64Js.fromByteArray = fromByteArray;
985
+
986
+ var lookup = [];
987
+ var revLookup = [];
988
+ var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
989
+
990
+ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
991
+ for (var i = 0, len = code.length; i < len; ++i) {
992
+ lookup[i] = code[i];
993
+ revLookup[code.charCodeAt(i)] = i;
994
+ }
995
+
996
+ // Support decoding URL-safe base64 strings, as Node.js does.
997
+ // See: https://en.wikipedia.org/wiki/Base64#URL_applications
998
+ revLookup['-'.charCodeAt(0)] = 62;
999
+ revLookup['_'.charCodeAt(0)] = 63;
1000
+
1001
+ function getLens (b64) {
1002
+ var len = b64.length;
1003
+
1004
+ if (len % 4 > 0) {
1005
+ throw new Error('Invalid string. Length must be a multiple of 4')
1006
+ }
1007
+
1008
+ // Trim off extra bytes after placeholder bytes are found
1009
+ // See: https://github.com/beatgammit/base64-js/issues/42
1010
+ var validLen = b64.indexOf('=');
1011
+ if (validLen === -1) validLen = len;
1012
+
1013
+ var placeHoldersLen = validLen === len
1014
+ ? 0
1015
+ : 4 - (validLen % 4);
1016
+
1017
+ return [validLen, placeHoldersLen]
1018
+ }
1019
+
1020
+ // base64 is 4/3 + up to two characters of the original data
1021
+ function byteLength (b64) {
1022
+ var lens = getLens(b64);
1023
+ var validLen = lens[0];
1024
+ var placeHoldersLen = lens[1];
1025
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
1026
+ }
1027
+
1028
+ function _byteLength (b64, validLen, placeHoldersLen) {
1029
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
1030
+ }
1031
+
1032
+ function toByteArray (b64) {
1033
+ var tmp;
1034
+ var lens = getLens(b64);
1035
+ var validLen = lens[0];
1036
+ var placeHoldersLen = lens[1];
1037
+
1038
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
1039
+
1040
+ var curByte = 0;
1041
+
1042
+ // if there are placeholders, only get up to the last complete 4 chars
1043
+ var len = placeHoldersLen > 0
1044
+ ? validLen - 4
1045
+ : validLen;
1046
+
1047
+ var i;
1048
+ for (i = 0; i < len; i += 4) {
1049
+ tmp =
1050
+ (revLookup[b64.charCodeAt(i)] << 18) |
1051
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
1052
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
1053
+ revLookup[b64.charCodeAt(i + 3)];
1054
+ arr[curByte++] = (tmp >> 16) & 0xFF;
1055
+ arr[curByte++] = (tmp >> 8) & 0xFF;
1056
+ arr[curByte++] = tmp & 0xFF;
1057
+ }
1058
+
1059
+ if (placeHoldersLen === 2) {
1060
+ tmp =
1061
+ (revLookup[b64.charCodeAt(i)] << 2) |
1062
+ (revLookup[b64.charCodeAt(i + 1)] >> 4);
1063
+ arr[curByte++] = tmp & 0xFF;
1064
+ }
1065
+
1066
+ if (placeHoldersLen === 1) {
1067
+ tmp =
1068
+ (revLookup[b64.charCodeAt(i)] << 10) |
1069
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
1070
+ (revLookup[b64.charCodeAt(i + 2)] >> 2);
1071
+ arr[curByte++] = (tmp >> 8) & 0xFF;
1072
+ arr[curByte++] = tmp & 0xFF;
1073
+ }
1074
+
1075
+ return arr
1076
+ }
1077
+
1078
+ function tripletToBase64 (num) {
1079
+ return lookup[num >> 18 & 0x3F] +
1080
+ lookup[num >> 12 & 0x3F] +
1081
+ lookup[num >> 6 & 0x3F] +
1082
+ lookup[num & 0x3F]
1083
+ }
1084
+
1085
+ function encodeChunk (uint8, start, end) {
1086
+ var tmp;
1087
+ var output = [];
1088
+ for (var i = start; i < end; i += 3) {
1089
+ tmp =
1090
+ ((uint8[i] << 16) & 0xFF0000) +
1091
+ ((uint8[i + 1] << 8) & 0xFF00) +
1092
+ (uint8[i + 2] & 0xFF);
1093
+ output.push(tripletToBase64(tmp));
1094
+ }
1095
+ return output.join('')
1096
+ }
1097
+
1098
+ function fromByteArray (uint8) {
1099
+ var tmp;
1100
+ var len = uint8.length;
1101
+ var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
1102
+ var parts = [];
1103
+ var maxChunkLength = 16383; // must be multiple of 3
1104
+
1105
+ // go through the array every three bytes, we'll deal with trailing stuff later
1106
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
1107
+ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
1108
+ }
1109
+
1110
+ // pad the end with zeros, but make sure to not forget the extra bytes
1111
+ if (extraBytes === 1) {
1112
+ tmp = uint8[len - 1];
1113
+ parts.push(
1114
+ lookup[tmp >> 2] +
1115
+ lookup[(tmp << 4) & 0x3F] +
1116
+ '=='
1117
+ );
1118
+ } else if (extraBytes === 2) {
1119
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
1120
+ parts.push(
1121
+ lookup[tmp >> 10] +
1122
+ lookup[(tmp >> 4) & 0x3F] +
1123
+ lookup[(tmp << 2) & 0x3F] +
1124
+ '='
1125
+ );
1126
+ }
1127
+
1128
+ return parts.join('')
1129
+ }
1130
+
1131
+ var ieee754 = {};
1132
+
1133
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
1134
+
1135
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
1136
+ var e, m;
1137
+ var eLen = (nBytes * 8) - mLen - 1;
1138
+ var eMax = (1 << eLen) - 1;
1139
+ var eBias = eMax >> 1;
1140
+ var nBits = -7;
1141
+ var i = isLE ? (nBytes - 1) : 0;
1142
+ var d = isLE ? -1 : 1;
1143
+ var s = buffer[offset + i];
1144
+
1145
+ i += d;
1146
+
1147
+ e = s & ((1 << (-nBits)) - 1);
1148
+ s >>= (-nBits);
1149
+ nBits += eLen;
1150
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
1151
+
1152
+ m = e & ((1 << (-nBits)) - 1);
1153
+ e >>= (-nBits);
1154
+ nBits += mLen;
1155
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
1156
+
1157
+ if (e === 0) {
1158
+ e = 1 - eBias;
1159
+ } else if (e === eMax) {
1160
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
1161
+ } else {
1162
+ m = m + Math.pow(2, mLen);
1163
+ e = e - eBias;
1164
+ }
1165
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
1166
+ };
1167
+
1168
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
1169
+ var e, m, c;
1170
+ var eLen = (nBytes * 8) - mLen - 1;
1171
+ var eMax = (1 << eLen) - 1;
1172
+ var eBias = eMax >> 1;
1173
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
1174
+ var i = isLE ? 0 : (nBytes - 1);
1175
+ var d = isLE ? 1 : -1;
1176
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
1177
+
1178
+ value = Math.abs(value);
1179
+
1180
+ if (isNaN(value) || value === Infinity) {
1181
+ m = isNaN(value) ? 1 : 0;
1182
+ e = eMax;
1183
+ } else {
1184
+ e = Math.floor(Math.log(value) / Math.LN2);
1185
+ if (value * (c = Math.pow(2, -e)) < 1) {
1186
+ e--;
1187
+ c *= 2;
1188
+ }
1189
+ if (e + eBias >= 1) {
1190
+ value += rt / c;
1191
+ } else {
1192
+ value += rt * Math.pow(2, 1 - eBias);
1193
+ }
1194
+ if (value * c >= 2) {
1195
+ e++;
1196
+ c /= 2;
1197
+ }
1198
+
1199
+ if (e + eBias >= eMax) {
1200
+ m = 0;
1201
+ e = eMax;
1202
+ } else if (e + eBias >= 1) {
1203
+ m = ((value * c) - 1) * Math.pow(2, mLen);
1204
+ e = e + eBias;
1205
+ } else {
1206
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1207
+ e = 0;
1208
+ }
1209
+ }
1210
+
1211
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
1212
+
1213
+ e = (e << mLen) | m;
1214
+ eLen += mLen;
1215
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
1216
+
1217
+ buffer[offset + i - d] |= s * 128;
1218
+ };
1219
+
1220
+ /*!
1221
+ * The buffer module from node.js, for the browser.
1222
+ *
1223
+ * @author Feross Aboukhadijeh <https://feross.org>
1224
+ * @license MIT
1225
+ */
1226
+
1227
+ (function (exports) {
1228
+
1229
+ const base64 = base64Js;
1230
+ const ieee754$1 = ieee754;
1231
+ const customInspectSymbol =
1232
+ (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
1233
+ ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
1234
+ : null;
1235
+
1236
+ exports.Buffer = Buffer;
1237
+ exports.SlowBuffer = SlowBuffer;
1238
+ exports.INSPECT_MAX_BYTES = 50;
1239
+
1240
+ const K_MAX_LENGTH = 0x7fffffff;
1241
+ exports.kMaxLength = K_MAX_LENGTH;
1242
+
1243
+ /**
1244
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
1245
+ * === true Use Uint8Array implementation (fastest)
1246
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
1247
+ * implementation (most compatible, even IE6)
1248
+ *
1249
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
1250
+ * Opera 11.6+, iOS 4.2+.
1251
+ *
1252
+ * We report that the browser does not support typed arrays if the are not subclassable
1253
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
1254
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
1255
+ * for __proto__ and has a buggy typed array implementation.
1256
+ */
1257
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
1258
+
1259
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
1260
+ typeof console.error === 'function') {
1261
+ console.error(
1262
+ 'This browser lacks typed array (Uint8Array) support which is required by ' +
1263
+ '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
1264
+ );
1265
+ }
1266
+
1267
+ function typedArraySupport () {
1268
+ // Can typed array instances can be augmented?
1269
+ try {
1270
+ const arr = new Uint8Array(1);
1271
+ const proto = { foo: function () { return 42 } };
1272
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
1273
+ Object.setPrototypeOf(arr, proto);
1274
+ return arr.foo() === 42
1275
+ } catch (e) {
1276
+ return false
1277
+ }
1278
+ }
1279
+
1280
+ Object.defineProperty(Buffer.prototype, 'parent', {
1281
+ enumerable: true,
1282
+ get: function () {
1283
+ if (!Buffer.isBuffer(this)) return undefined
1284
+ return this.buffer
1285
+ }
1286
+ });
1287
+
1288
+ Object.defineProperty(Buffer.prototype, 'offset', {
1289
+ enumerable: true,
1290
+ get: function () {
1291
+ if (!Buffer.isBuffer(this)) return undefined
1292
+ return this.byteOffset
1293
+ }
1294
+ });
1295
+
1296
+ function createBuffer (length) {
1297
+ if (length > K_MAX_LENGTH) {
1298
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
1299
+ }
1300
+ // Return an augmented `Uint8Array` instance
1301
+ const buf = new Uint8Array(length);
1302
+ Object.setPrototypeOf(buf, Buffer.prototype);
1303
+ return buf
1304
+ }
1305
+
1306
+ /**
1307
+ * The Buffer constructor returns instances of `Uint8Array` that have their
1308
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
1309
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
1310
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
1311
+ * returns a single octet.
1312
+ *
1313
+ * The `Uint8Array` prototype remains unmodified.
1314
+ */
1315
+
1316
+ function Buffer (arg, encodingOrOffset, length) {
1317
+ // Common case.
1318
+ if (typeof arg === 'number') {
1319
+ if (typeof encodingOrOffset === 'string') {
1320
+ throw new TypeError(
1321
+ 'The "string" argument must be of type string. Received type number'
1322
+ )
1323
+ }
1324
+ return allocUnsafe(arg)
1325
+ }
1326
+ return from(arg, encodingOrOffset, length)
1327
+ }
1328
+
1329
+ Buffer.poolSize = 8192; // not used by this implementation
1330
+
1331
+ function from (value, encodingOrOffset, length) {
1332
+ if (typeof value === 'string') {
1333
+ return fromString(value, encodingOrOffset)
1334
+ }
1335
+
1336
+ if (ArrayBuffer.isView(value)) {
1337
+ return fromArrayView(value)
1338
+ }
1339
+
1340
+ if (value == null) {
1341
+ throw new TypeError(
1342
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
1343
+ 'or Array-like Object. Received type ' + (typeof value)
1344
+ )
1345
+ }
1346
+
1347
+ if (isInstance(value, ArrayBuffer) ||
1348
+ (value && isInstance(value.buffer, ArrayBuffer))) {
1349
+ return fromArrayBuffer(value, encodingOrOffset, length)
1350
+ }
1351
+
1352
+ if (typeof SharedArrayBuffer !== 'undefined' &&
1353
+ (isInstance(value, SharedArrayBuffer) ||
1354
+ (value && isInstance(value.buffer, SharedArrayBuffer)))) {
1355
+ return fromArrayBuffer(value, encodingOrOffset, length)
1356
+ }
1357
+
1358
+ if (typeof value === 'number') {
1359
+ throw new TypeError(
1360
+ 'The "value" argument must not be of type number. Received type number'
1361
+ )
1362
+ }
1363
+
1364
+ const valueOf = value.valueOf && value.valueOf();
1365
+ if (valueOf != null && valueOf !== value) {
1366
+ return Buffer.from(valueOf, encodingOrOffset, length)
1367
+ }
1368
+
1369
+ const b = fromObject(value);
1370
+ if (b) return b
1371
+
1372
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
1373
+ typeof value[Symbol.toPrimitive] === 'function') {
1374
+ return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
1375
+ }
1376
+
1377
+ throw new TypeError(
1378
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
1379
+ 'or Array-like Object. Received type ' + (typeof value)
1380
+ )
1381
+ }
1382
+
1383
+ /**
1384
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
1385
+ * if value is a number.
1386
+ * Buffer.from(str[, encoding])
1387
+ * Buffer.from(array)
1388
+ * Buffer.from(buffer)
1389
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
1390
+ **/
1391
+ Buffer.from = function (value, encodingOrOffset, length) {
1392
+ return from(value, encodingOrOffset, length)
1393
+ };
1394
+
1395
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
1396
+ // https://github.com/feross/buffer/pull/148
1397
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
1398
+ Object.setPrototypeOf(Buffer, Uint8Array);
1399
+
1400
+ function assertSize (size) {
1401
+ if (typeof size !== 'number') {
1402
+ throw new TypeError('"size" argument must be of type number')
1403
+ } else if (size < 0) {
1404
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
1405
+ }
1406
+ }
1407
+
1408
+ function alloc (size, fill, encoding) {
1409
+ assertSize(size);
1410
+ if (size <= 0) {
1411
+ return createBuffer(size)
1412
+ }
1413
+ if (fill !== undefined) {
1414
+ // Only pay attention to encoding if it's a string. This
1415
+ // prevents accidentally sending in a number that would
1416
+ // be interpreted as a start offset.
1417
+ return typeof encoding === 'string'
1418
+ ? createBuffer(size).fill(fill, encoding)
1419
+ : createBuffer(size).fill(fill)
1420
+ }
1421
+ return createBuffer(size)
1422
+ }
1423
+
1424
+ /**
1425
+ * Creates a new filled Buffer instance.
1426
+ * alloc(size[, fill[, encoding]])
1427
+ **/
1428
+ Buffer.alloc = function (size, fill, encoding) {
1429
+ return alloc(size, fill, encoding)
1430
+ };
1431
+
1432
+ function allocUnsafe (size) {
1433
+ assertSize(size);
1434
+ return createBuffer(size < 0 ? 0 : checked(size) | 0)
1435
+ }
1436
+
1437
+ /**
1438
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
1439
+ * */
1440
+ Buffer.allocUnsafe = function (size) {
1441
+ return allocUnsafe(size)
1442
+ };
1443
+ /**
1444
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
1445
+ */
1446
+ Buffer.allocUnsafeSlow = function (size) {
1447
+ return allocUnsafe(size)
1448
+ };
1449
+
1450
+ function fromString (string, encoding) {
1451
+ if (typeof encoding !== 'string' || encoding === '') {
1452
+ encoding = 'utf8';
1453
+ }
1454
+
1455
+ if (!Buffer.isEncoding(encoding)) {
1456
+ throw new TypeError('Unknown encoding: ' + encoding)
1457
+ }
1458
+
1459
+ const length = byteLength(string, encoding) | 0;
1460
+ let buf = createBuffer(length);
1461
+
1462
+ const actual = buf.write(string, encoding);
1463
+
1464
+ if (actual !== length) {
1465
+ // Writing a hex string, for example, that contains invalid characters will
1466
+ // cause everything after the first invalid character to be ignored. (e.g.
1467
+ // 'abxxcd' will be treated as 'ab')
1468
+ buf = buf.slice(0, actual);
1469
+ }
1470
+
1471
+ return buf
1472
+ }
1473
+
1474
+ function fromArrayLike (array) {
1475
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
1476
+ const buf = createBuffer(length);
1477
+ for (let i = 0; i < length; i += 1) {
1478
+ buf[i] = array[i] & 255;
1479
+ }
1480
+ return buf
1481
+ }
1482
+
1483
+ function fromArrayView (arrayView) {
1484
+ if (isInstance(arrayView, Uint8Array)) {
1485
+ const copy = new Uint8Array(arrayView);
1486
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
1487
+ }
1488
+ return fromArrayLike(arrayView)
1489
+ }
1490
+
1491
+ function fromArrayBuffer (array, byteOffset, length) {
1492
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
1493
+ throw new RangeError('"offset" is outside of buffer bounds')
1494
+ }
1495
+
1496
+ if (array.byteLength < byteOffset + (length || 0)) {
1497
+ throw new RangeError('"length" is outside of buffer bounds')
1498
+ }
1499
+
1500
+ let buf;
1501
+ if (byteOffset === undefined && length === undefined) {
1502
+ buf = new Uint8Array(array);
1503
+ } else if (length === undefined) {
1504
+ buf = new Uint8Array(array, byteOffset);
1505
+ } else {
1506
+ buf = new Uint8Array(array, byteOffset, length);
1507
+ }
1508
+
1509
+ // Return an augmented `Uint8Array` instance
1510
+ Object.setPrototypeOf(buf, Buffer.prototype);
1511
+
1512
+ return buf
1513
+ }
1514
+
1515
+ function fromObject (obj) {
1516
+ if (Buffer.isBuffer(obj)) {
1517
+ const len = checked(obj.length) | 0;
1518
+ const buf = createBuffer(len);
1519
+
1520
+ if (buf.length === 0) {
1521
+ return buf
1522
+ }
1523
+
1524
+ obj.copy(buf, 0, 0, len);
1525
+ return buf
1526
+ }
1527
+
1528
+ if (obj.length !== undefined) {
1529
+ if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
1530
+ return createBuffer(0)
1531
+ }
1532
+ return fromArrayLike(obj)
1533
+ }
1534
+
1535
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
1536
+ return fromArrayLike(obj.data)
1537
+ }
1538
+ }
1539
+
1540
+ function checked (length) {
1541
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
1542
+ // length is NaN (which is otherwise coerced to zero.)
1543
+ if (length >= K_MAX_LENGTH) {
1544
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
1545
+ 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
1546
+ }
1547
+ return length | 0
1548
+ }
1549
+
1550
+ function SlowBuffer (length) {
1551
+ if (+length != length) { // eslint-disable-line eqeqeq
1552
+ length = 0;
1553
+ }
1554
+ return Buffer.alloc(+length)
1555
+ }
1556
+
1557
+ Buffer.isBuffer = function isBuffer (b) {
1558
+ return b != null && b._isBuffer === true &&
1559
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
1560
+ };
1561
+
1562
+ Buffer.compare = function compare (a, b) {
1563
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
1564
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
1565
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
1566
+ throw new TypeError(
1567
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
1568
+ )
1569
+ }
1570
+
1571
+ if (a === b) return 0
1572
+
1573
+ let x = a.length;
1574
+ let y = b.length;
1575
+
1576
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
1577
+ if (a[i] !== b[i]) {
1578
+ x = a[i];
1579
+ y = b[i];
1580
+ break
1581
+ }
1582
+ }
1583
+
1584
+ if (x < y) return -1
1585
+ if (y < x) return 1
1586
+ return 0
1587
+ };
1588
+
1589
+ Buffer.isEncoding = function isEncoding (encoding) {
1590
+ switch (String(encoding).toLowerCase()) {
1591
+ case 'hex':
1592
+ case 'utf8':
1593
+ case 'utf-8':
1594
+ case 'ascii':
1595
+ case 'latin1':
1596
+ case 'binary':
1597
+ case 'base64':
1598
+ case 'ucs2':
1599
+ case 'ucs-2':
1600
+ case 'utf16le':
1601
+ case 'utf-16le':
1602
+ return true
1603
+ default:
1604
+ return false
1605
+ }
1606
+ };
1607
+
1608
+ Buffer.concat = function concat (list, length) {
1609
+ if (!Array.isArray(list)) {
1610
+ throw new TypeError('"list" argument must be an Array of Buffers')
1611
+ }
1612
+
1613
+ if (list.length === 0) {
1614
+ return Buffer.alloc(0)
1615
+ }
1616
+
1617
+ let i;
1618
+ if (length === undefined) {
1619
+ length = 0;
1620
+ for (i = 0; i < list.length; ++i) {
1621
+ length += list[i].length;
1622
+ }
1623
+ }
1624
+
1625
+ const buffer = Buffer.allocUnsafe(length);
1626
+ let pos = 0;
1627
+ for (i = 0; i < list.length; ++i) {
1628
+ let buf = list[i];
1629
+ if (isInstance(buf, Uint8Array)) {
1630
+ if (pos + buf.length > buffer.length) {
1631
+ if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf);
1632
+ buf.copy(buffer, pos);
1633
+ } else {
1634
+ Uint8Array.prototype.set.call(
1635
+ buffer,
1636
+ buf,
1637
+ pos
1638
+ );
1639
+ }
1640
+ } else if (!Buffer.isBuffer(buf)) {
1641
+ throw new TypeError('"list" argument must be an Array of Buffers')
1642
+ } else {
1643
+ buf.copy(buffer, pos);
1644
+ }
1645
+ pos += buf.length;
1646
+ }
1647
+ return buffer
1648
+ };
1649
+
1650
+ function byteLength (string, encoding) {
1651
+ if (Buffer.isBuffer(string)) {
1652
+ return string.length
1653
+ }
1654
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
1655
+ return string.byteLength
1656
+ }
1657
+ if (typeof string !== 'string') {
1658
+ throw new TypeError(
1659
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
1660
+ 'Received type ' + typeof string
1661
+ )
1662
+ }
1663
+
1664
+ const len = string.length;
1665
+ const mustMatch = (arguments.length > 2 && arguments[2] === true);
1666
+ if (!mustMatch && len === 0) return 0
1667
+
1668
+ // Use a for loop to avoid recursion
1669
+ let loweredCase = false;
1670
+ for (;;) {
1671
+ switch (encoding) {
1672
+ case 'ascii':
1673
+ case 'latin1':
1674
+ case 'binary':
1675
+ return len
1676
+ case 'utf8':
1677
+ case 'utf-8':
1678
+ return utf8ToBytes(string).length
1679
+ case 'ucs2':
1680
+ case 'ucs-2':
1681
+ case 'utf16le':
1682
+ case 'utf-16le':
1683
+ return len * 2
1684
+ case 'hex':
1685
+ return len >>> 1
1686
+ case 'base64':
1687
+ return base64ToBytes(string).length
1688
+ default:
1689
+ if (loweredCase) {
1690
+ return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
1691
+ }
1692
+ encoding = ('' + encoding).toLowerCase();
1693
+ loweredCase = true;
1694
+ }
1695
+ }
1696
+ }
1697
+ Buffer.byteLength = byteLength;
1698
+
1699
+ function slowToString (encoding, start, end) {
1700
+ let loweredCase = false;
1701
+
1702
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1703
+ // property of a typed array.
1704
+
1705
+ // This behaves neither like String nor Uint8Array in that we set start/end
1706
+ // to their upper/lower bounds if the value passed is out of range.
1707
+ // undefined is handled specially as per ECMA-262 6th Edition,
1708
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1709
+ if (start === undefined || start < 0) {
1710
+ start = 0;
1711
+ }
1712
+ // Return early if start > this.length. Done here to prevent potential uint32
1713
+ // coercion fail below.
1714
+ if (start > this.length) {
1715
+ return ''
1716
+ }
1717
+
1718
+ if (end === undefined || end > this.length) {
1719
+ end = this.length;
1720
+ }
1721
+
1722
+ if (end <= 0) {
1723
+ return ''
1724
+ }
1725
+
1726
+ // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
1727
+ end >>>= 0;
1728
+ start >>>= 0;
1729
+
1730
+ if (end <= start) {
1731
+ return ''
1732
+ }
1733
+
1734
+ if (!encoding) encoding = 'utf8';
1735
+
1736
+ while (true) {
1737
+ switch (encoding) {
1738
+ case 'hex':
1739
+ return hexSlice(this, start, end)
1740
+
1741
+ case 'utf8':
1742
+ case 'utf-8':
1743
+ return utf8Slice(this, start, end)
1744
+
1745
+ case 'ascii':
1746
+ return asciiSlice(this, start, end)
1747
+
1748
+ case 'latin1':
1749
+ case 'binary':
1750
+ return latin1Slice(this, start, end)
1751
+
1752
+ case 'base64':
1753
+ return base64Slice(this, start, end)
1754
+
1755
+ case 'ucs2':
1756
+ case 'ucs-2':
1757
+ case 'utf16le':
1758
+ case 'utf-16le':
1759
+ return utf16leSlice(this, start, end)
1760
+
1761
+ default:
1762
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1763
+ encoding = (encoding + '').toLowerCase();
1764
+ loweredCase = true;
1765
+ }
1766
+ }
1767
+ }
1768
+
1769
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
1770
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
1771
+ // reliably in a browserify context because there could be multiple different
1772
+ // copies of the 'buffer' package in use. This method works even for Buffer
1773
+ // instances that were created from another copy of the `buffer` package.
1774
+ // See: https://github.com/feross/buffer/issues/154
1775
+ Buffer.prototype._isBuffer = true;
1776
+
1777
+ function swap (b, n, m) {
1778
+ const i = b[n];
1779
+ b[n] = b[m];
1780
+ b[m] = i;
1781
+ }
1782
+
1783
+ Buffer.prototype.swap16 = function swap16 () {
1784
+ const len = this.length;
1785
+ if (len % 2 !== 0) {
1786
+ throw new RangeError('Buffer size must be a multiple of 16-bits')
1787
+ }
1788
+ for (let i = 0; i < len; i += 2) {
1789
+ swap(this, i, i + 1);
1790
+ }
1791
+ return this
1792
+ };
1793
+
1794
+ Buffer.prototype.swap32 = function swap32 () {
1795
+ const len = this.length;
1796
+ if (len % 4 !== 0) {
1797
+ throw new RangeError('Buffer size must be a multiple of 32-bits')
1798
+ }
1799
+ for (let i = 0; i < len; i += 4) {
1800
+ swap(this, i, i + 3);
1801
+ swap(this, i + 1, i + 2);
1802
+ }
1803
+ return this
1804
+ };
1805
+
1806
+ Buffer.prototype.swap64 = function swap64 () {
1807
+ const len = this.length;
1808
+ if (len % 8 !== 0) {
1809
+ throw new RangeError('Buffer size must be a multiple of 64-bits')
1810
+ }
1811
+ for (let i = 0; i < len; i += 8) {
1812
+ swap(this, i, i + 7);
1813
+ swap(this, i + 1, i + 6);
1814
+ swap(this, i + 2, i + 5);
1815
+ swap(this, i + 3, i + 4);
1816
+ }
1817
+ return this
1818
+ };
1819
+
1820
+ Buffer.prototype.toString = function toString () {
1821
+ const length = this.length;
1822
+ if (length === 0) return ''
1823
+ if (arguments.length === 0) return utf8Slice(this, 0, length)
1824
+ return slowToString.apply(this, arguments)
1825
+ };
1826
+
1827
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
1828
+
1829
+ Buffer.prototype.equals = function equals (b) {
1830
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1831
+ if (this === b) return true
1832
+ return Buffer.compare(this, b) === 0
1833
+ };
1834
+
1835
+ Buffer.prototype.inspect = function inspect () {
1836
+ let str = '';
1837
+ const max = exports.INSPECT_MAX_BYTES;
1838
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
1839
+ if (this.length > max) str += ' ... ';
1840
+ return '<Buffer ' + str + '>'
1841
+ };
1842
+ if (customInspectSymbol) {
1843
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
1844
+ }
1845
+
1846
+ Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1847
+ if (isInstance(target, Uint8Array)) {
1848
+ target = Buffer.from(target, target.offset, target.byteLength);
1849
+ }
1850
+ if (!Buffer.isBuffer(target)) {
1851
+ throw new TypeError(
1852
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
1853
+ 'Received type ' + (typeof target)
1854
+ )
1855
+ }
1856
+
1857
+ if (start === undefined) {
1858
+ start = 0;
1859
+ }
1860
+ if (end === undefined) {
1861
+ end = target ? target.length : 0;
1862
+ }
1863
+ if (thisStart === undefined) {
1864
+ thisStart = 0;
1865
+ }
1866
+ if (thisEnd === undefined) {
1867
+ thisEnd = this.length;
1868
+ }
1869
+
1870
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1871
+ throw new RangeError('out of range index')
1872
+ }
1873
+
1874
+ if (thisStart >= thisEnd && start >= end) {
1875
+ return 0
1876
+ }
1877
+ if (thisStart >= thisEnd) {
1878
+ return -1
1879
+ }
1880
+ if (start >= end) {
1881
+ return 1
1882
+ }
1883
+
1884
+ start >>>= 0;
1885
+ end >>>= 0;
1886
+ thisStart >>>= 0;
1887
+ thisEnd >>>= 0;
1888
+
1889
+ if (this === target) return 0
1890
+
1891
+ let x = thisEnd - thisStart;
1892
+ let y = end - start;
1893
+ const len = Math.min(x, y);
1894
+
1895
+ const thisCopy = this.slice(thisStart, thisEnd);
1896
+ const targetCopy = target.slice(start, end);
1897
+
1898
+ for (let i = 0; i < len; ++i) {
1899
+ if (thisCopy[i] !== targetCopy[i]) {
1900
+ x = thisCopy[i];
1901
+ y = targetCopy[i];
1902
+ break
1903
+ }
1904
+ }
1905
+
1906
+ if (x < y) return -1
1907
+ if (y < x) return 1
1908
+ return 0
1909
+ };
1910
+
1911
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1912
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1913
+ //
1914
+ // Arguments:
1915
+ // - buffer - a Buffer to search
1916
+ // - val - a string, Buffer, or number
1917
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
1918
+ // - encoding - an optional encoding, relevant is val is a string
1919
+ // - dir - true for indexOf, false for lastIndexOf
1920
+ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1921
+ // Empty buffer means no match
1922
+ if (buffer.length === 0) return -1
1923
+
1924
+ // Normalize byteOffset
1925
+ if (typeof byteOffset === 'string') {
1926
+ encoding = byteOffset;
1927
+ byteOffset = 0;
1928
+ } else if (byteOffset > 0x7fffffff) {
1929
+ byteOffset = 0x7fffffff;
1930
+ } else if (byteOffset < -0x80000000) {
1931
+ byteOffset = -0x80000000;
1932
+ }
1933
+ byteOffset = +byteOffset; // Coerce to Number.
1934
+ if (numberIsNaN(byteOffset)) {
1935
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1936
+ byteOffset = dir ? 0 : (buffer.length - 1);
1937
+ }
1938
+
1939
+ // Normalize byteOffset: negative offsets start from the end of the buffer
1940
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
1941
+ if (byteOffset >= buffer.length) {
1942
+ if (dir) return -1
1943
+ else byteOffset = buffer.length - 1;
1944
+ } else if (byteOffset < 0) {
1945
+ if (dir) byteOffset = 0;
1946
+ else return -1
1947
+ }
1948
+
1949
+ // Normalize val
1950
+ if (typeof val === 'string') {
1951
+ val = Buffer.from(val, encoding);
1952
+ }
1953
+
1954
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
1955
+ if (Buffer.isBuffer(val)) {
1956
+ // Special case: looking for empty string/buffer always fails
1957
+ if (val.length === 0) {
1958
+ return -1
1959
+ }
1960
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1961
+ } else if (typeof val === 'number') {
1962
+ val = val & 0xFF; // Search for a byte value [0-255]
1963
+ if (typeof Uint8Array.prototype.indexOf === 'function') {
1964
+ if (dir) {
1965
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1966
+ } else {
1967
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1968
+ }
1969
+ }
1970
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
1971
+ }
1972
+
1973
+ throw new TypeError('val must be string, number or Buffer')
1974
+ }
1975
+
1976
+ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1977
+ let indexSize = 1;
1978
+ let arrLength = arr.length;
1979
+ let valLength = val.length;
1980
+
1981
+ if (encoding !== undefined) {
1982
+ encoding = String(encoding).toLowerCase();
1983
+ if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1984
+ encoding === 'utf16le' || encoding === 'utf-16le') {
1985
+ if (arr.length < 2 || val.length < 2) {
1986
+ return -1
1987
+ }
1988
+ indexSize = 2;
1989
+ arrLength /= 2;
1990
+ valLength /= 2;
1991
+ byteOffset /= 2;
1992
+ }
1993
+ }
1994
+
1995
+ function read (buf, i) {
1996
+ if (indexSize === 1) {
1997
+ return buf[i]
1998
+ } else {
1999
+ return buf.readUInt16BE(i * indexSize)
2000
+ }
2001
+ }
2002
+
2003
+ let i;
2004
+ if (dir) {
2005
+ let foundIndex = -1;
2006
+ for (i = byteOffset; i < arrLength; i++) {
2007
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
2008
+ if (foundIndex === -1) foundIndex = i;
2009
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
2010
+ } else {
2011
+ if (foundIndex !== -1) i -= i - foundIndex;
2012
+ foundIndex = -1;
2013
+ }
2014
+ }
2015
+ } else {
2016
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
2017
+ for (i = byteOffset; i >= 0; i--) {
2018
+ let found = true;
2019
+ for (let j = 0; j < valLength; j++) {
2020
+ if (read(arr, i + j) !== read(val, j)) {
2021
+ found = false;
2022
+ break
2023
+ }
2024
+ }
2025
+ if (found) return i
2026
+ }
2027
+ }
2028
+
2029
+ return -1
2030
+ }
2031
+
2032
+ Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
2033
+ return this.indexOf(val, byteOffset, encoding) !== -1
2034
+ };
2035
+
2036
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
2037
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
2038
+ };
2039
+
2040
+ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
2041
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
2042
+ };
2043
+
2044
+ function hexWrite (buf, string, offset, length) {
2045
+ offset = Number(offset) || 0;
2046
+ const remaining = buf.length - offset;
2047
+ if (!length) {
2048
+ length = remaining;
2049
+ } else {
2050
+ length = Number(length);
2051
+ if (length > remaining) {
2052
+ length = remaining;
2053
+ }
2054
+ }
2055
+
2056
+ const strLen = string.length;
2057
+
2058
+ if (length > strLen / 2) {
2059
+ length = strLen / 2;
2060
+ }
2061
+ let i;
2062
+ for (i = 0; i < length; ++i) {
2063
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
2064
+ if (numberIsNaN(parsed)) return i
2065
+ buf[offset + i] = parsed;
2066
+ }
2067
+ return i
2068
+ }
2069
+
2070
+ function utf8Write (buf, string, offset, length) {
2071
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
2072
+ }
2073
+
2074
+ function asciiWrite (buf, string, offset, length) {
2075
+ return blitBuffer(asciiToBytes(string), buf, offset, length)
2076
+ }
2077
+
2078
+ function base64Write (buf, string, offset, length) {
2079
+ return blitBuffer(base64ToBytes(string), buf, offset, length)
2080
+ }
2081
+
2082
+ function ucs2Write (buf, string, offset, length) {
2083
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
2084
+ }
2085
+
2086
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
2087
+ // Buffer#write(string)
2088
+ if (offset === undefined) {
2089
+ encoding = 'utf8';
2090
+ length = this.length;
2091
+ offset = 0;
2092
+ // Buffer#write(string, encoding)
2093
+ } else if (length === undefined && typeof offset === 'string') {
2094
+ encoding = offset;
2095
+ length = this.length;
2096
+ offset = 0;
2097
+ // Buffer#write(string, offset[, length][, encoding])
2098
+ } else if (isFinite(offset)) {
2099
+ offset = offset >>> 0;
2100
+ if (isFinite(length)) {
2101
+ length = length >>> 0;
2102
+ if (encoding === undefined) encoding = 'utf8';
2103
+ } else {
2104
+ encoding = length;
2105
+ length = undefined;
2106
+ }
2107
+ } else {
2108
+ throw new Error(
2109
+ 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
2110
+ )
2111
+ }
2112
+
2113
+ const remaining = this.length - offset;
2114
+ if (length === undefined || length > remaining) length = remaining;
2115
+
2116
+ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
2117
+ throw new RangeError('Attempt to write outside buffer bounds')
2118
+ }
2119
+
2120
+ if (!encoding) encoding = 'utf8';
2121
+
2122
+ let loweredCase = false;
2123
+ for (;;) {
2124
+ switch (encoding) {
2125
+ case 'hex':
2126
+ return hexWrite(this, string, offset, length)
2127
+
2128
+ case 'utf8':
2129
+ case 'utf-8':
2130
+ return utf8Write(this, string, offset, length)
2131
+
2132
+ case 'ascii':
2133
+ case 'latin1':
2134
+ case 'binary':
2135
+ return asciiWrite(this, string, offset, length)
2136
+
2137
+ case 'base64':
2138
+ // Warning: maxLength not taken into account in base64Write
2139
+ return base64Write(this, string, offset, length)
2140
+
2141
+ case 'ucs2':
2142
+ case 'ucs-2':
2143
+ case 'utf16le':
2144
+ case 'utf-16le':
2145
+ return ucs2Write(this, string, offset, length)
2146
+
2147
+ default:
2148
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
2149
+ encoding = ('' + encoding).toLowerCase();
2150
+ loweredCase = true;
2151
+ }
2152
+ }
2153
+ };
2154
+
2155
+ Buffer.prototype.toJSON = function toJSON () {
2156
+ return {
2157
+ type: 'Buffer',
2158
+ data: Array.prototype.slice.call(this._arr || this, 0)
2159
+ }
2160
+ };
2161
+
2162
+ function base64Slice (buf, start, end) {
2163
+ if (start === 0 && end === buf.length) {
2164
+ return base64.fromByteArray(buf)
2165
+ } else {
2166
+ return base64.fromByteArray(buf.slice(start, end))
2167
+ }
2168
+ }
2169
+
2170
+ function utf8Slice (buf, start, end) {
2171
+ end = Math.min(buf.length, end);
2172
+ const res = [];
2173
+
2174
+ let i = start;
2175
+ while (i < end) {
2176
+ const firstByte = buf[i];
2177
+ let codePoint = null;
2178
+ let bytesPerSequence = (firstByte > 0xEF)
2179
+ ? 4
2180
+ : (firstByte > 0xDF)
2181
+ ? 3
2182
+ : (firstByte > 0xBF)
2183
+ ? 2
2184
+ : 1;
2185
+
2186
+ if (i + bytesPerSequence <= end) {
2187
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
2188
+
2189
+ switch (bytesPerSequence) {
2190
+ case 1:
2191
+ if (firstByte < 0x80) {
2192
+ codePoint = firstByte;
2193
+ }
2194
+ break
2195
+ case 2:
2196
+ secondByte = buf[i + 1];
2197
+ if ((secondByte & 0xC0) === 0x80) {
2198
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
2199
+ if (tempCodePoint > 0x7F) {
2200
+ codePoint = tempCodePoint;
2201
+ }
2202
+ }
2203
+ break
2204
+ case 3:
2205
+ secondByte = buf[i + 1];
2206
+ thirdByte = buf[i + 2];
2207
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
2208
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
2209
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
2210
+ codePoint = tempCodePoint;
2211
+ }
2212
+ }
2213
+ break
2214
+ case 4:
2215
+ secondByte = buf[i + 1];
2216
+ thirdByte = buf[i + 2];
2217
+ fourthByte = buf[i + 3];
2218
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
2219
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
2220
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
2221
+ codePoint = tempCodePoint;
2222
+ }
2223
+ }
2224
+ }
2225
+ }
2226
+
2227
+ if (codePoint === null) {
2228
+ // we did not generate a valid codePoint so insert a
2229
+ // replacement char (U+FFFD) and advance only 1 byte
2230
+ codePoint = 0xFFFD;
2231
+ bytesPerSequence = 1;
2232
+ } else if (codePoint > 0xFFFF) {
2233
+ // encode to utf16 (surrogate pair dance)
2234
+ codePoint -= 0x10000;
2235
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800);
2236
+ codePoint = 0xDC00 | codePoint & 0x3FF;
2237
+ }
2238
+
2239
+ res.push(codePoint);
2240
+ i += bytesPerSequence;
2241
+ }
2242
+
2243
+ return decodeCodePointsArray(res)
2244
+ }
2245
+
2246
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
2247
+ // the lowest limit is Chrome, with 0x10000 args.
2248
+ // We go 1 magnitude less, for safety
2249
+ const MAX_ARGUMENTS_LENGTH = 0x1000;
2250
+
2251
+ function decodeCodePointsArray (codePoints) {
2252
+ const len = codePoints.length;
2253
+ if (len <= MAX_ARGUMENTS_LENGTH) {
2254
+ return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
2255
+ }
2256
+
2257
+ // Decode in chunks to avoid "call stack size exceeded".
2258
+ let res = '';
2259
+ let i = 0;
2260
+ while (i < len) {
2261
+ res += String.fromCharCode.apply(
2262
+ String,
2263
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
2264
+ );
2265
+ }
2266
+ return res
2267
+ }
2268
+
2269
+ function asciiSlice (buf, start, end) {
2270
+ let ret = '';
2271
+ end = Math.min(buf.length, end);
2272
+
2273
+ for (let i = start; i < end; ++i) {
2274
+ ret += String.fromCharCode(buf[i] & 0x7F);
2275
+ }
2276
+ return ret
2277
+ }
2278
+
2279
+ function latin1Slice (buf, start, end) {
2280
+ let ret = '';
2281
+ end = Math.min(buf.length, end);
2282
+
2283
+ for (let i = start; i < end; ++i) {
2284
+ ret += String.fromCharCode(buf[i]);
2285
+ }
2286
+ return ret
2287
+ }
2288
+
2289
+ function hexSlice (buf, start, end) {
2290
+ const len = buf.length;
2291
+
2292
+ if (!start || start < 0) start = 0;
2293
+ if (!end || end < 0 || end > len) end = len;
2294
+
2295
+ let out = '';
2296
+ for (let i = start; i < end; ++i) {
2297
+ out += hexSliceLookupTable[buf[i]];
2298
+ }
2299
+ return out
2300
+ }
2301
+
2302
+ function utf16leSlice (buf, start, end) {
2303
+ const bytes = buf.slice(start, end);
2304
+ let res = '';
2305
+ // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
2306
+ for (let i = 0; i < bytes.length - 1; i += 2) {
2307
+ res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
2308
+ }
2309
+ return res
2310
+ }
2311
+
2312
+ Buffer.prototype.slice = function slice (start, end) {
2313
+ const len = this.length;
2314
+ start = ~~start;
2315
+ end = end === undefined ? len : ~~end;
2316
+
2317
+ if (start < 0) {
2318
+ start += len;
2319
+ if (start < 0) start = 0;
2320
+ } else if (start > len) {
2321
+ start = len;
2322
+ }
2323
+
2324
+ if (end < 0) {
2325
+ end += len;
2326
+ if (end < 0) end = 0;
2327
+ } else if (end > len) {
2328
+ end = len;
2329
+ }
2330
+
2331
+ if (end < start) end = start;
2332
+
2333
+ const newBuf = this.subarray(start, end);
2334
+ // Return an augmented `Uint8Array` instance
2335
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
2336
+
2337
+ return newBuf
2338
+ };
2339
+
2340
+ /*
2341
+ * Need to make sure that buffer isn't trying to write out of bounds.
2342
+ */
2343
+ function checkOffset (offset, ext, length) {
2344
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
2345
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
2346
+ }
2347
+
2348
+ Buffer.prototype.readUintLE =
2349
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
2350
+ offset = offset >>> 0;
2351
+ byteLength = byteLength >>> 0;
2352
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
2353
+
2354
+ let val = this[offset];
2355
+ let mul = 1;
2356
+ let i = 0;
2357
+ while (++i < byteLength && (mul *= 0x100)) {
2358
+ val += this[offset + i] * mul;
2359
+ }
2360
+
2361
+ return val
2362
+ };
2363
+
2364
+ Buffer.prototype.readUintBE =
2365
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
2366
+ offset = offset >>> 0;
2367
+ byteLength = byteLength >>> 0;
2368
+ if (!noAssert) {
2369
+ checkOffset(offset, byteLength, this.length);
2370
+ }
2371
+
2372
+ let val = this[offset + --byteLength];
2373
+ let mul = 1;
2374
+ while (byteLength > 0 && (mul *= 0x100)) {
2375
+ val += this[offset + --byteLength] * mul;
2376
+ }
2377
+
2378
+ return val
2379
+ };
2380
+
2381
+ Buffer.prototype.readUint8 =
2382
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
2383
+ offset = offset >>> 0;
2384
+ if (!noAssert) checkOffset(offset, 1, this.length);
2385
+ return this[offset]
2386
+ };
2387
+
2388
+ Buffer.prototype.readUint16LE =
2389
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
2390
+ offset = offset >>> 0;
2391
+ if (!noAssert) checkOffset(offset, 2, this.length);
2392
+ return this[offset] | (this[offset + 1] << 8)
2393
+ };
2394
+
2395
+ Buffer.prototype.readUint16BE =
2396
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
2397
+ offset = offset >>> 0;
2398
+ if (!noAssert) checkOffset(offset, 2, this.length);
2399
+ return (this[offset] << 8) | this[offset + 1]
2400
+ };
2401
+
2402
+ Buffer.prototype.readUint32LE =
2403
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
2404
+ offset = offset >>> 0;
2405
+ if (!noAssert) checkOffset(offset, 4, this.length);
2406
+
2407
+ return ((this[offset]) |
2408
+ (this[offset + 1] << 8) |
2409
+ (this[offset + 2] << 16)) +
2410
+ (this[offset + 3] * 0x1000000)
2411
+ };
2412
+
2413
+ Buffer.prototype.readUint32BE =
2414
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
2415
+ offset = offset >>> 0;
2416
+ if (!noAssert) checkOffset(offset, 4, this.length);
2417
+
2418
+ return (this[offset] * 0x1000000) +
2419
+ ((this[offset + 1] << 16) |
2420
+ (this[offset + 2] << 8) |
2421
+ this[offset + 3])
2422
+ };
2423
+
2424
+ Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
2425
+ offset = offset >>> 0;
2426
+ validateNumber(offset, 'offset');
2427
+ const first = this[offset];
2428
+ const last = this[offset + 7];
2429
+ if (first === undefined || last === undefined) {
2430
+ boundsError(offset, this.length - 8);
2431
+ }
2432
+
2433
+ const lo = first +
2434
+ this[++offset] * 2 ** 8 +
2435
+ this[++offset] * 2 ** 16 +
2436
+ this[++offset] * 2 ** 24;
2437
+
2438
+ const hi = this[++offset] +
2439
+ this[++offset] * 2 ** 8 +
2440
+ this[++offset] * 2 ** 16 +
2441
+ last * 2 ** 24;
2442
+
2443
+ return BigInt(lo) + (BigInt(hi) << BigInt(32))
2444
+ });
2445
+
2446
+ Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
2447
+ offset = offset >>> 0;
2448
+ validateNumber(offset, 'offset');
2449
+ const first = this[offset];
2450
+ const last = this[offset + 7];
2451
+ if (first === undefined || last === undefined) {
2452
+ boundsError(offset, this.length - 8);
2453
+ }
2454
+
2455
+ const hi = first * 2 ** 24 +
2456
+ this[++offset] * 2 ** 16 +
2457
+ this[++offset] * 2 ** 8 +
2458
+ this[++offset];
2459
+
2460
+ const lo = this[++offset] * 2 ** 24 +
2461
+ this[++offset] * 2 ** 16 +
2462
+ this[++offset] * 2 ** 8 +
2463
+ last;
2464
+
2465
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo)
2466
+ });
2467
+
2468
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
2469
+ offset = offset >>> 0;
2470
+ byteLength = byteLength >>> 0;
2471
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
2472
+
2473
+ let val = this[offset];
2474
+ let mul = 1;
2475
+ let i = 0;
2476
+ while (++i < byteLength && (mul *= 0x100)) {
2477
+ val += this[offset + i] * mul;
2478
+ }
2479
+ mul *= 0x80;
2480
+
2481
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
2482
+
2483
+ return val
2484
+ };
2485
+
2486
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
2487
+ offset = offset >>> 0;
2488
+ byteLength = byteLength >>> 0;
2489
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
2490
+
2491
+ let i = byteLength;
2492
+ let mul = 1;
2493
+ let val = this[offset + --i];
2494
+ while (i > 0 && (mul *= 0x100)) {
2495
+ val += this[offset + --i] * mul;
2496
+ }
2497
+ mul *= 0x80;
2498
+
2499
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
2500
+
2501
+ return val
2502
+ };
2503
+
2504
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
2505
+ offset = offset >>> 0;
2506
+ if (!noAssert) checkOffset(offset, 1, this.length);
2507
+ if (!(this[offset] & 0x80)) return (this[offset])
2508
+ return ((0xff - this[offset] + 1) * -1)
2509
+ };
2510
+
2511
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
2512
+ offset = offset >>> 0;
2513
+ if (!noAssert) checkOffset(offset, 2, this.length);
2514
+ const val = this[offset] | (this[offset + 1] << 8);
2515
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
2516
+ };
2517
+
2518
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
2519
+ offset = offset >>> 0;
2520
+ if (!noAssert) checkOffset(offset, 2, this.length);
2521
+ const val = this[offset + 1] | (this[offset] << 8);
2522
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
2523
+ };
2524
+
2525
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
2526
+ offset = offset >>> 0;
2527
+ if (!noAssert) checkOffset(offset, 4, this.length);
2528
+
2529
+ return (this[offset]) |
2530
+ (this[offset + 1] << 8) |
2531
+ (this[offset + 2] << 16) |
2532
+ (this[offset + 3] << 24)
2533
+ };
2534
+
2535
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
2536
+ offset = offset >>> 0;
2537
+ if (!noAssert) checkOffset(offset, 4, this.length);
2538
+
2539
+ return (this[offset] << 24) |
2540
+ (this[offset + 1] << 16) |
2541
+ (this[offset + 2] << 8) |
2542
+ (this[offset + 3])
2543
+ };
2544
+
2545
+ Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
2546
+ offset = offset >>> 0;
2547
+ validateNumber(offset, 'offset');
2548
+ const first = this[offset];
2549
+ const last = this[offset + 7];
2550
+ if (first === undefined || last === undefined) {
2551
+ boundsError(offset, this.length - 8);
2552
+ }
2553
+
2554
+ const val = this[offset + 4] +
2555
+ this[offset + 5] * 2 ** 8 +
2556
+ this[offset + 6] * 2 ** 16 +
2557
+ (last << 24); // Overflow
2558
+
2559
+ return (BigInt(val) << BigInt(32)) +
2560
+ BigInt(first +
2561
+ this[++offset] * 2 ** 8 +
2562
+ this[++offset] * 2 ** 16 +
2563
+ this[++offset] * 2 ** 24)
2564
+ });
2565
+
2566
+ Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
2567
+ offset = offset >>> 0;
2568
+ validateNumber(offset, 'offset');
2569
+ const first = this[offset];
2570
+ const last = this[offset + 7];
2571
+ if (first === undefined || last === undefined) {
2572
+ boundsError(offset, this.length - 8);
2573
+ }
2574
+
2575
+ const val = (first << 24) + // Overflow
2576
+ this[++offset] * 2 ** 16 +
2577
+ this[++offset] * 2 ** 8 +
2578
+ this[++offset];
2579
+
2580
+ return (BigInt(val) << BigInt(32)) +
2581
+ BigInt(this[++offset] * 2 ** 24 +
2582
+ this[++offset] * 2 ** 16 +
2583
+ this[++offset] * 2 ** 8 +
2584
+ last)
2585
+ });
2586
+
2587
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
2588
+ offset = offset >>> 0;
2589
+ if (!noAssert) checkOffset(offset, 4, this.length);
2590
+ return ieee754$1.read(this, offset, true, 23, 4)
2591
+ };
2592
+
2593
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
2594
+ offset = offset >>> 0;
2595
+ if (!noAssert) checkOffset(offset, 4, this.length);
2596
+ return ieee754$1.read(this, offset, false, 23, 4)
2597
+ };
2598
+
2599
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
2600
+ offset = offset >>> 0;
2601
+ if (!noAssert) checkOffset(offset, 8, this.length);
2602
+ return ieee754$1.read(this, offset, true, 52, 8)
2603
+ };
2604
+
2605
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
2606
+ offset = offset >>> 0;
2607
+ if (!noAssert) checkOffset(offset, 8, this.length);
2608
+ return ieee754$1.read(this, offset, false, 52, 8)
2609
+ };
2610
+
2611
+ function checkInt (buf, value, offset, ext, max, min) {
2612
+ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
2613
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
2614
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
2615
+ }
2616
+
2617
+ Buffer.prototype.writeUintLE =
2618
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
2619
+ value = +value;
2620
+ offset = offset >>> 0;
2621
+ byteLength = byteLength >>> 0;
2622
+ if (!noAssert) {
2623
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
2624
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
2625
+ }
2626
+
2627
+ let mul = 1;
2628
+ let i = 0;
2629
+ this[offset] = value & 0xFF;
2630
+ while (++i < byteLength && (mul *= 0x100)) {
2631
+ this[offset + i] = (value / mul) & 0xFF;
2632
+ }
2633
+
2634
+ return offset + byteLength
2635
+ };
2636
+
2637
+ Buffer.prototype.writeUintBE =
2638
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
2639
+ value = +value;
2640
+ offset = offset >>> 0;
2641
+ byteLength = byteLength >>> 0;
2642
+ if (!noAssert) {
2643
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
2644
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
2645
+ }
2646
+
2647
+ let i = byteLength - 1;
2648
+ let mul = 1;
2649
+ this[offset + i] = value & 0xFF;
2650
+ while (--i >= 0 && (mul *= 0x100)) {
2651
+ this[offset + i] = (value / mul) & 0xFF;
2652
+ }
2653
+
2654
+ return offset + byteLength
2655
+ };
2656
+
2657
+ Buffer.prototype.writeUint8 =
2658
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
2659
+ value = +value;
2660
+ offset = offset >>> 0;
2661
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
2662
+ this[offset] = (value & 0xff);
2663
+ return offset + 1
2664
+ };
2665
+
2666
+ Buffer.prototype.writeUint16LE =
2667
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
2668
+ value = +value;
2669
+ offset = offset >>> 0;
2670
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
2671
+ this[offset] = (value & 0xff);
2672
+ this[offset + 1] = (value >>> 8);
2673
+ return offset + 2
2674
+ };
2675
+
2676
+ Buffer.prototype.writeUint16BE =
2677
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
2678
+ value = +value;
2679
+ offset = offset >>> 0;
2680
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
2681
+ this[offset] = (value >>> 8);
2682
+ this[offset + 1] = (value & 0xff);
2683
+ return offset + 2
2684
+ };
2685
+
2686
+ Buffer.prototype.writeUint32LE =
2687
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
2688
+ value = +value;
2689
+ offset = offset >>> 0;
2690
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
2691
+ this[offset + 3] = (value >>> 24);
2692
+ this[offset + 2] = (value >>> 16);
2693
+ this[offset + 1] = (value >>> 8);
2694
+ this[offset] = (value & 0xff);
2695
+ return offset + 4
2696
+ };
2697
+
2698
+ Buffer.prototype.writeUint32BE =
2699
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
2700
+ value = +value;
2701
+ offset = offset >>> 0;
2702
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
2703
+ this[offset] = (value >>> 24);
2704
+ this[offset + 1] = (value >>> 16);
2705
+ this[offset + 2] = (value >>> 8);
2706
+ this[offset + 3] = (value & 0xff);
2707
+ return offset + 4
2708
+ };
2709
+
2710
+ function wrtBigUInt64LE (buf, value, offset, min, max) {
2711
+ checkIntBI(value, min, max, buf, offset, 7);
2712
+
2713
+ let lo = Number(value & BigInt(0xffffffff));
2714
+ buf[offset++] = lo;
2715
+ lo = lo >> 8;
2716
+ buf[offset++] = lo;
2717
+ lo = lo >> 8;
2718
+ buf[offset++] = lo;
2719
+ lo = lo >> 8;
2720
+ buf[offset++] = lo;
2721
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
2722
+ buf[offset++] = hi;
2723
+ hi = hi >> 8;
2724
+ buf[offset++] = hi;
2725
+ hi = hi >> 8;
2726
+ buf[offset++] = hi;
2727
+ hi = hi >> 8;
2728
+ buf[offset++] = hi;
2729
+ return offset
2730
+ }
2731
+
2732
+ function wrtBigUInt64BE (buf, value, offset, min, max) {
2733
+ checkIntBI(value, min, max, buf, offset, 7);
2734
+
2735
+ let lo = Number(value & BigInt(0xffffffff));
2736
+ buf[offset + 7] = lo;
2737
+ lo = lo >> 8;
2738
+ buf[offset + 6] = lo;
2739
+ lo = lo >> 8;
2740
+ buf[offset + 5] = lo;
2741
+ lo = lo >> 8;
2742
+ buf[offset + 4] = lo;
2743
+ let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));
2744
+ buf[offset + 3] = hi;
2745
+ hi = hi >> 8;
2746
+ buf[offset + 2] = hi;
2747
+ hi = hi >> 8;
2748
+ buf[offset + 1] = hi;
2749
+ hi = hi >> 8;
2750
+ buf[offset] = hi;
2751
+ return offset + 8
2752
+ }
2753
+
2754
+ Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
2755
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
2756
+ });
2757
+
2758
+ Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
2759
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
2760
+ });
2761
+
2762
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
2763
+ value = +value;
2764
+ offset = offset >>> 0;
2765
+ if (!noAssert) {
2766
+ const limit = Math.pow(2, (8 * byteLength) - 1);
2767
+
2768
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
2769
+ }
2770
+
2771
+ let i = 0;
2772
+ let mul = 1;
2773
+ let sub = 0;
2774
+ this[offset] = value & 0xFF;
2775
+ while (++i < byteLength && (mul *= 0x100)) {
2776
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2777
+ sub = 1;
2778
+ }
2779
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
2780
+ }
2781
+
2782
+ return offset + byteLength
2783
+ };
2784
+
2785
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
2786
+ value = +value;
2787
+ offset = offset >>> 0;
2788
+ if (!noAssert) {
2789
+ const limit = Math.pow(2, (8 * byteLength) - 1);
2790
+
2791
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
2792
+ }
2793
+
2794
+ let i = byteLength - 1;
2795
+ let mul = 1;
2796
+ let sub = 0;
2797
+ this[offset + i] = value & 0xFF;
2798
+ while (--i >= 0 && (mul *= 0x100)) {
2799
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2800
+ sub = 1;
2801
+ }
2802
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
2803
+ }
2804
+
2805
+ return offset + byteLength
2806
+ };
2807
+
2808
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2809
+ value = +value;
2810
+ offset = offset >>> 0;
2811
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80);
2812
+ if (value < 0) value = 0xff + value + 1;
2813
+ this[offset] = (value & 0xff);
2814
+ return offset + 1
2815
+ };
2816
+
2817
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2818
+ value = +value;
2819
+ offset = offset >>> 0;
2820
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
2821
+ this[offset] = (value & 0xff);
2822
+ this[offset + 1] = (value >>> 8);
2823
+ return offset + 2
2824
+ };
2825
+
2826
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2827
+ value = +value;
2828
+ offset = offset >>> 0;
2829
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000);
2830
+ this[offset] = (value >>> 8);
2831
+ this[offset + 1] = (value & 0xff);
2832
+ return offset + 2
2833
+ };
2834
+
2835
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2836
+ value = +value;
2837
+ offset = offset >>> 0;
2838
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
2839
+ this[offset] = (value & 0xff);
2840
+ this[offset + 1] = (value >>> 8);
2841
+ this[offset + 2] = (value >>> 16);
2842
+ this[offset + 3] = (value >>> 24);
2843
+ return offset + 4
2844
+ };
2845
+
2846
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2847
+ value = +value;
2848
+ offset = offset >>> 0;
2849
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
2850
+ if (value < 0) value = 0xffffffff + value + 1;
2851
+ this[offset] = (value >>> 24);
2852
+ this[offset + 1] = (value >>> 16);
2853
+ this[offset + 2] = (value >>> 8);
2854
+ this[offset + 3] = (value & 0xff);
2855
+ return offset + 4
2856
+ };
2857
+
2858
+ Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
2859
+ return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
2860
+ });
2861
+
2862
+ Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
2863
+ return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
2864
+ });
2865
+
2866
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
2867
+ if (offset + ext > buf.length) throw new RangeError('Index out of range')
2868
+ if (offset < 0) throw new RangeError('Index out of range')
2869
+ }
2870
+
2871
+ function writeFloat (buf, value, offset, littleEndian, noAssert) {
2872
+ value = +value;
2873
+ offset = offset >>> 0;
2874
+ if (!noAssert) {
2875
+ checkIEEE754(buf, value, offset, 4);
2876
+ }
2877
+ ieee754$1.write(buf, value, offset, littleEndian, 23, 4);
2878
+ return offset + 4
2879
+ }
2880
+
2881
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2882
+ return writeFloat(this, value, offset, true, noAssert)
2883
+ };
2884
+
2885
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2886
+ return writeFloat(this, value, offset, false, noAssert)
2887
+ };
2888
+
2889
+ function writeDouble (buf, value, offset, littleEndian, noAssert) {
2890
+ value = +value;
2891
+ offset = offset >>> 0;
2892
+ if (!noAssert) {
2893
+ checkIEEE754(buf, value, offset, 8);
2894
+ }
2895
+ ieee754$1.write(buf, value, offset, littleEndian, 52, 8);
2896
+ return offset + 8
2897
+ }
2898
+
2899
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2900
+ return writeDouble(this, value, offset, true, noAssert)
2901
+ };
2902
+
2903
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2904
+ return writeDouble(this, value, offset, false, noAssert)
2905
+ };
2906
+
2907
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2908
+ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2909
+ if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
2910
+ if (!start) start = 0;
2911
+ if (!end && end !== 0) end = this.length;
2912
+ if (targetStart >= target.length) targetStart = target.length;
2913
+ if (!targetStart) targetStart = 0;
2914
+ if (end > 0 && end < start) end = start;
2915
+
2916
+ // Copy 0 bytes; we're done
2917
+ if (end === start) return 0
2918
+ if (target.length === 0 || this.length === 0) return 0
2919
+
2920
+ // Fatal error conditions
2921
+ if (targetStart < 0) {
2922
+ throw new RangeError('targetStart out of bounds')
2923
+ }
2924
+ if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
2925
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
2926
+
2927
+ // Are we oob?
2928
+ if (end > this.length) end = this.length;
2929
+ if (target.length - targetStart < end - start) {
2930
+ end = target.length - targetStart + start;
2931
+ }
2932
+
2933
+ const len = end - start;
2934
+
2935
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
2936
+ // Use built-in when available, missing from IE11
2937
+ this.copyWithin(targetStart, start, end);
2938
+ } else {
2939
+ Uint8Array.prototype.set.call(
2940
+ target,
2941
+ this.subarray(start, end),
2942
+ targetStart
2943
+ );
2944
+ }
2945
+
2946
+ return len
2947
+ };
2948
+
2949
+ // Usage:
2950
+ // buffer.fill(number[, offset[, end]])
2951
+ // buffer.fill(buffer[, offset[, end]])
2952
+ // buffer.fill(string[, offset[, end]][, encoding])
2953
+ Buffer.prototype.fill = function fill (val, start, end, encoding) {
2954
+ // Handle string cases:
2955
+ if (typeof val === 'string') {
2956
+ if (typeof start === 'string') {
2957
+ encoding = start;
2958
+ start = 0;
2959
+ end = this.length;
2960
+ } else if (typeof end === 'string') {
2961
+ encoding = end;
2962
+ end = this.length;
2963
+ }
2964
+ if (encoding !== undefined && typeof encoding !== 'string') {
2965
+ throw new TypeError('encoding must be a string')
2966
+ }
2967
+ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2968
+ throw new TypeError('Unknown encoding: ' + encoding)
2969
+ }
2970
+ if (val.length === 1) {
2971
+ const code = val.charCodeAt(0);
2972
+ if ((encoding === 'utf8' && code < 128) ||
2973
+ encoding === 'latin1') {
2974
+ // Fast path: If `val` fits into a single byte, use that numeric value.
2975
+ val = code;
2976
+ }
2977
+ }
2978
+ } else if (typeof val === 'number') {
2979
+ val = val & 255;
2980
+ } else if (typeof val === 'boolean') {
2981
+ val = Number(val);
2982
+ }
2983
+
2984
+ // Invalid ranges are not set to a default, so can range check early.
2985
+ if (start < 0 || this.length < start || this.length < end) {
2986
+ throw new RangeError('Out of range index')
2987
+ }
2988
+
2989
+ if (end <= start) {
2990
+ return this
2991
+ }
2992
+
2993
+ start = start >>> 0;
2994
+ end = end === undefined ? this.length : end >>> 0;
2995
+
2996
+ if (!val) val = 0;
2997
+
2998
+ let i;
2999
+ if (typeof val === 'number') {
3000
+ for (i = start; i < end; ++i) {
3001
+ this[i] = val;
3002
+ }
3003
+ } else {
3004
+ const bytes = Buffer.isBuffer(val)
3005
+ ? val
3006
+ : Buffer.from(val, encoding);
3007
+ const len = bytes.length;
3008
+ if (len === 0) {
3009
+ throw new TypeError('The value "' + val +
3010
+ '" is invalid for argument "value"')
3011
+ }
3012
+ for (i = 0; i < end - start; ++i) {
3013
+ this[i + start] = bytes[i % len];
3014
+ }
3015
+ }
3016
+
3017
+ return this
3018
+ };
3019
+
3020
+ // CUSTOM ERRORS
3021
+ // =============
3022
+
3023
+ // Simplified versions from Node, changed for Buffer-only usage
3024
+ const errors = {};
3025
+ function E (sym, getMessage, Base) {
3026
+ errors[sym] = class NodeError extends Base {
3027
+ constructor () {
3028
+ super();
3029
+
3030
+ Object.defineProperty(this, 'message', {
3031
+ value: getMessage.apply(this, arguments),
3032
+ writable: true,
3033
+ configurable: true
3034
+ });
3035
+
3036
+ // Add the error code to the name to include it in the stack trace.
3037
+ this.name = `${this.name} [${sym}]`;
3038
+ // Access the stack to generate the error message including the error code
3039
+ // from the name.
3040
+ this.stack; // eslint-disable-line no-unused-expressions
3041
+ // Reset the name to the actual name.
3042
+ delete this.name;
3043
+ }
3044
+
3045
+ get code () {
3046
+ return sym
3047
+ }
3048
+
3049
+ set code (value) {
3050
+ Object.defineProperty(this, 'code', {
3051
+ configurable: true,
3052
+ enumerable: true,
3053
+ value,
3054
+ writable: true
3055
+ });
3056
+ }
3057
+
3058
+ toString () {
3059
+ return `${this.name} [${sym}]: ${this.message}`
3060
+ }
3061
+ };
3062
+ }
3063
+
3064
+ E('ERR_BUFFER_OUT_OF_BOUNDS',
3065
+ function (name) {
3066
+ if (name) {
3067
+ return `${name} is outside of buffer bounds`
3068
+ }
3069
+
3070
+ return 'Attempt to access memory outside buffer bounds'
3071
+ }, RangeError);
3072
+ E('ERR_INVALID_ARG_TYPE',
3073
+ function (name, actual) {
3074
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`
3075
+ }, TypeError);
3076
+ E('ERR_OUT_OF_RANGE',
3077
+ function (str, range, input) {
3078
+ let msg = `The value of "${str}" is out of range.`;
3079
+ let received = input;
3080
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
3081
+ received = addNumericalSeparator(String(input));
3082
+ } else if (typeof input === 'bigint') {
3083
+ received = String(input);
3084
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
3085
+ received = addNumericalSeparator(received);
3086
+ }
3087
+ received += 'n';
3088
+ }
3089
+ msg += ` It must be ${range}. Received ${received}`;
3090
+ return msg
3091
+ }, RangeError);
3092
+
3093
+ function addNumericalSeparator (val) {
3094
+ let res = '';
3095
+ let i = val.length;
3096
+ const start = val[0] === '-' ? 1 : 0;
3097
+ for (; i >= start + 4; i -= 3) {
3098
+ res = `_${val.slice(i - 3, i)}${res}`;
3099
+ }
3100
+ return `${val.slice(0, i)}${res}`
3101
+ }
3102
+
3103
+ // CHECK FUNCTIONS
3104
+ // ===============
3105
+
3106
+ function checkBounds (buf, offset, byteLength) {
3107
+ validateNumber(offset, 'offset');
3108
+ if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
3109
+ boundsError(offset, buf.length - (byteLength + 1));
3110
+ }
3111
+ }
3112
+
3113
+ function checkIntBI (value, min, max, buf, offset, byteLength) {
3114
+ if (value > max || value < min) {
3115
+ const n = typeof min === 'bigint' ? 'n' : '';
3116
+ let range;
3117
+ if (byteLength > 3) {
3118
+ if (min === 0 || min === BigInt(0)) {
3119
+ range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
3120
+ } else {
3121
+ range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
3122
+ `${(byteLength + 1) * 8 - 1}${n}`;
3123
+ }
3124
+ } else {
3125
+ range = `>= ${min}${n} and <= ${max}${n}`;
3126
+ }
3127
+ throw new errors.ERR_OUT_OF_RANGE('value', range, value)
3128
+ }
3129
+ checkBounds(buf, offset, byteLength);
3130
+ }
3131
+
3132
+ function validateNumber (value, name) {
3133
+ if (typeof value !== 'number') {
3134
+ throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
3135
+ }
3136
+ }
3137
+
3138
+ function boundsError (value, length, type) {
3139
+ if (Math.floor(value) !== value) {
3140
+ validateNumber(value, type);
3141
+ throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
3142
+ }
3143
+
3144
+ if (length < 0) {
3145
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
3146
+ }
3147
+
3148
+ throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
3149
+ `>= ${type ? 1 : 0} and <= ${length}`,
3150
+ value)
3151
+ }
3152
+
3153
+ // HELPER FUNCTIONS
3154
+ // ================
3155
+
3156
+ const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
3157
+
3158
+ function base64clean (str) {
3159
+ // Node takes equal signs as end of the Base64 encoding
3160
+ str = str.split('=')[0];
3161
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
3162
+ str = str.trim().replace(INVALID_BASE64_RE, '');
3163
+ // Node converts strings with length < 2 to ''
3164
+ if (str.length < 2) return ''
3165
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
3166
+ while (str.length % 4 !== 0) {
3167
+ str = str + '=';
3168
+ }
3169
+ return str
3170
+ }
3171
+
3172
+ function utf8ToBytes (string, units) {
3173
+ units = units || Infinity;
3174
+ let codePoint;
3175
+ const length = string.length;
3176
+ let leadSurrogate = null;
3177
+ const bytes = [];
3178
+
3179
+ for (let i = 0; i < length; ++i) {
3180
+ codePoint = string.charCodeAt(i);
3181
+
3182
+ // is surrogate component
3183
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
3184
+ // last char was a lead
3185
+ if (!leadSurrogate) {
3186
+ // no lead yet
3187
+ if (codePoint > 0xDBFF) {
3188
+ // unexpected trail
3189
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3190
+ continue
3191
+ } else if (i + 1 === length) {
3192
+ // unpaired lead
3193
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3194
+ continue
3195
+ }
3196
+
3197
+ // valid lead
3198
+ leadSurrogate = codePoint;
3199
+
3200
+ continue
3201
+ }
3202
+
3203
+ // 2 leads in a row
3204
+ if (codePoint < 0xDC00) {
3205
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3206
+ leadSurrogate = codePoint;
3207
+ continue
3208
+ }
3209
+
3210
+ // valid surrogate pair
3211
+ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
3212
+ } else if (leadSurrogate) {
3213
+ // valid bmp char, but last char was a lead
3214
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3215
+ }
3216
+
3217
+ leadSurrogate = null;
3218
+
3219
+ // encode utf8
3220
+ if (codePoint < 0x80) {
3221
+ if ((units -= 1) < 0) break
3222
+ bytes.push(codePoint);
3223
+ } else if (codePoint < 0x800) {
3224
+ if ((units -= 2) < 0) break
3225
+ bytes.push(
3226
+ codePoint >> 0x6 | 0xC0,
3227
+ codePoint & 0x3F | 0x80
3228
+ );
3229
+ } else if (codePoint < 0x10000) {
3230
+ if ((units -= 3) < 0) break
3231
+ bytes.push(
3232
+ codePoint >> 0xC | 0xE0,
3233
+ codePoint >> 0x6 & 0x3F | 0x80,
3234
+ codePoint & 0x3F | 0x80
3235
+ );
3236
+ } else if (codePoint < 0x110000) {
3237
+ if ((units -= 4) < 0) break
3238
+ bytes.push(
3239
+ codePoint >> 0x12 | 0xF0,
3240
+ codePoint >> 0xC & 0x3F | 0x80,
3241
+ codePoint >> 0x6 & 0x3F | 0x80,
3242
+ codePoint & 0x3F | 0x80
3243
+ );
3244
+ } else {
3245
+ throw new Error('Invalid code point')
3246
+ }
3247
+ }
3248
+
3249
+ return bytes
3250
+ }
3251
+
3252
+ function asciiToBytes (str) {
3253
+ const byteArray = [];
3254
+ for (let i = 0; i < str.length; ++i) {
3255
+ // Node's code seems to be doing this and not & 0x7F..
3256
+ byteArray.push(str.charCodeAt(i) & 0xFF);
3257
+ }
3258
+ return byteArray
3259
+ }
3260
+
3261
+ function utf16leToBytes (str, units) {
3262
+ let c, hi, lo;
3263
+ const byteArray = [];
3264
+ for (let i = 0; i < str.length; ++i) {
3265
+ if ((units -= 2) < 0) break
3266
+
3267
+ c = str.charCodeAt(i);
3268
+ hi = c >> 8;
3269
+ lo = c % 256;
3270
+ byteArray.push(lo);
3271
+ byteArray.push(hi);
3272
+ }
3273
+
3274
+ return byteArray
3275
+ }
3276
+
3277
+ function base64ToBytes (str) {
3278
+ return base64.toByteArray(base64clean(str))
3279
+ }
3280
+
3281
+ function blitBuffer (src, dst, offset, length) {
3282
+ let i;
3283
+ for (i = 0; i < length; ++i) {
3284
+ if ((i + offset >= dst.length) || (i >= src.length)) break
3285
+ dst[i + offset] = src[i];
3286
+ }
3287
+ return i
3288
+ }
3289
+
3290
+ // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
3291
+ // the `instanceof` check but they should be treated as of that type.
3292
+ // See: https://github.com/feross/buffer/issues/166
3293
+ function isInstance (obj, type) {
3294
+ return obj instanceof type ||
3295
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
3296
+ obj.constructor.name === type.name)
3297
+ }
3298
+ function numberIsNaN (obj) {
3299
+ // For IE11 support
3300
+ return obj !== obj // eslint-disable-line no-self-compare
3301
+ }
3302
+
3303
+ // Create lookup table for `toString('hex')`
3304
+ // See: https://github.com/feross/buffer/issues/219
3305
+ const hexSliceLookupTable = (function () {
3306
+ const alphabet = '0123456789abcdef';
3307
+ const table = new Array(256);
3308
+ for (let i = 0; i < 16; ++i) {
3309
+ const i16 = i * 16;
3310
+ for (let j = 0; j < 16; ++j) {
3311
+ table[i16 + j] = alphabet[i] + alphabet[j];
3312
+ }
3313
+ }
3314
+ return table
3315
+ })();
3316
+
3317
+ // Return not function with Error if BigInt not supported
3318
+ function defineBigIntMethod (fn) {
3319
+ return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
3320
+ }
3321
+
3322
+ function BufferBigIntNotDefined () {
3323
+ throw new Error('BigInt not supported')
3324
+ }
3325
+ } (buffer));
3326
+
980
3327
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
981
3328
 
982
3329
  (function (module, exports) {
983
3330
  /* eslint-disable node/no-deprecated-api */
984
- var buffer = require$$0;
985
- var Buffer = buffer.Buffer;
3331
+ var buffer$1 = buffer;
3332
+ var Buffer = buffer$1.Buffer;
986
3333
 
987
3334
  // alternative to using Object.keys for old browsers
988
3335
  function copyProps (src, dst) {
@@ -991,10 +3338,10 @@ var safeBuffer = {
991
3338
  }
992
3339
  }
993
3340
  if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
994
- module.exports = buffer;
3341
+ module.exports = buffer$1;
995
3342
  } else {
996
3343
  // Copy properties from require('buffer')
997
- copyProps(buffer, exports);
3344
+ copyProps(buffer$1, exports);
998
3345
  exports.Buffer = SafeBuffer;
999
3346
  }
1000
3347
 
@@ -1042,7 +3389,7 @@ var safeBuffer = {
1042
3389
  if (typeof size !== 'number') {
1043
3390
  throw new TypeError('Argument must be a number')
1044
3391
  }
1045
- return buffer.SlowBuffer(size)
3392
+ return buffer$1.SlowBuffer(size)
1046
3393
  };
1047
3394
  } (safeBuffer, safeBufferExports));
1048
3395
 
@@ -1101,7 +3448,487 @@ var readableBrowser = {
1101
3448
  set exports(v){ readableBrowserExports = v; },
1102
3449
  };
1103
3450
 
1104
- var streamBrowser = require$$0$1.EventEmitter;
3451
+ var eventsExports = {};
3452
+ var events = {
3453
+ get exports(){ return eventsExports; },
3454
+ set exports(v){ eventsExports = v; },
3455
+ };
3456
+
3457
+ var R = typeof Reflect === 'object' ? Reflect : null;
3458
+ var ReflectApply = R && typeof R.apply === 'function'
3459
+ ? R.apply
3460
+ : function ReflectApply(target, receiver, args) {
3461
+ return Function.prototype.apply.call(target, receiver, args);
3462
+ };
3463
+
3464
+ var ReflectOwnKeys;
3465
+ if (R && typeof R.ownKeys === 'function') {
3466
+ ReflectOwnKeys = R.ownKeys;
3467
+ } else if (Object.getOwnPropertySymbols) {
3468
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
3469
+ return Object.getOwnPropertyNames(target)
3470
+ .concat(Object.getOwnPropertySymbols(target));
3471
+ };
3472
+ } else {
3473
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
3474
+ return Object.getOwnPropertyNames(target);
3475
+ };
3476
+ }
3477
+
3478
+ function ProcessEmitWarning(warning) {
3479
+ if (console && console.warn) console.warn(warning);
3480
+ }
3481
+
3482
+ var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
3483
+ return value !== value;
3484
+ };
3485
+
3486
+ function EventEmitter() {
3487
+ EventEmitter.init.call(this);
3488
+ }
3489
+ events.exports = EventEmitter;
3490
+ eventsExports.once = once$2;
3491
+
3492
+ // Backwards-compat with node 0.10.x
3493
+ EventEmitter.EventEmitter = EventEmitter;
3494
+
3495
+ EventEmitter.prototype._events = undefined;
3496
+ EventEmitter.prototype._eventsCount = 0;
3497
+ EventEmitter.prototype._maxListeners = undefined;
3498
+
3499
+ // By default EventEmitters will print a warning if more than 10 listeners are
3500
+ // added to it. This is a useful default which helps finding memory leaks.
3501
+ var defaultMaxListeners = 10;
3502
+
3503
+ function checkListener(listener) {
3504
+ if (typeof listener !== 'function') {
3505
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
3506
+ }
3507
+ }
3508
+
3509
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
3510
+ enumerable: true,
3511
+ get: function() {
3512
+ return defaultMaxListeners;
3513
+ },
3514
+ set: function(arg) {
3515
+ if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
3516
+ throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
3517
+ }
3518
+ defaultMaxListeners = arg;
3519
+ }
3520
+ });
3521
+
3522
+ EventEmitter.init = function() {
3523
+
3524
+ if (this._events === undefined ||
3525
+ this._events === Object.getPrototypeOf(this)._events) {
3526
+ this._events = Object.create(null);
3527
+ this._eventsCount = 0;
3528
+ }
3529
+
3530
+ this._maxListeners = this._maxListeners || undefined;
3531
+ };
3532
+
3533
+ // Obviously not all Emitters should be limited to 10. This function allows
3534
+ // that to be increased. Set to zero for unlimited.
3535
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
3536
+ if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
3537
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
3538
+ }
3539
+ this._maxListeners = n;
3540
+ return this;
3541
+ };
3542
+
3543
+ function _getMaxListeners(that) {
3544
+ if (that._maxListeners === undefined)
3545
+ return EventEmitter.defaultMaxListeners;
3546
+ return that._maxListeners;
3547
+ }
3548
+
3549
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
3550
+ return _getMaxListeners(this);
3551
+ };
3552
+
3553
+ EventEmitter.prototype.emit = function emit(type) {
3554
+ var args = [];
3555
+ for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
3556
+ var doError = (type === 'error');
3557
+
3558
+ var events = this._events;
3559
+ if (events !== undefined)
3560
+ doError = (doError && events.error === undefined);
3561
+ else if (!doError)
3562
+ return false;
3563
+
3564
+ // If there is no 'error' event listener then throw.
3565
+ if (doError) {
3566
+ var er;
3567
+ if (args.length > 0)
3568
+ er = args[0];
3569
+ if (er instanceof Error) {
3570
+ // Note: The comments on the `throw` lines are intentional, they show
3571
+ // up in Node's output if this results in an unhandled exception.
3572
+ throw er; // Unhandled 'error' event
3573
+ }
3574
+ // At least give some kind of context to the user
3575
+ var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
3576
+ err.context = er;
3577
+ throw err; // Unhandled 'error' event
3578
+ }
3579
+
3580
+ var handler = events[type];
3581
+
3582
+ if (handler === undefined)
3583
+ return false;
3584
+
3585
+ if (typeof handler === 'function') {
3586
+ ReflectApply(handler, this, args);
3587
+ } else {
3588
+ var len = handler.length;
3589
+ var listeners = arrayClone(handler, len);
3590
+ for (var i = 0; i < len; ++i)
3591
+ ReflectApply(listeners[i], this, args);
3592
+ }
3593
+
3594
+ return true;
3595
+ };
3596
+
3597
+ function _addListener(target, type, listener, prepend) {
3598
+ var m;
3599
+ var events;
3600
+ var existing;
3601
+
3602
+ checkListener(listener);
3603
+
3604
+ events = target._events;
3605
+ if (events === undefined) {
3606
+ events = target._events = Object.create(null);
3607
+ target._eventsCount = 0;
3608
+ } else {
3609
+ // To avoid recursion in the case that type === "newListener"! Before
3610
+ // adding it to the listeners, first emit "newListener".
3611
+ if (events.newListener !== undefined) {
3612
+ target.emit('newListener', type,
3613
+ listener.listener ? listener.listener : listener);
3614
+
3615
+ // Re-assign `events` because a newListener handler could have caused the
3616
+ // this._events to be assigned to a new object
3617
+ events = target._events;
3618
+ }
3619
+ existing = events[type];
3620
+ }
3621
+
3622
+ if (existing === undefined) {
3623
+ // Optimize the case of one listener. Don't need the extra array object.
3624
+ existing = events[type] = listener;
3625
+ ++target._eventsCount;
3626
+ } else {
3627
+ if (typeof existing === 'function') {
3628
+ // Adding the second element, need to change to array.
3629
+ existing = events[type] =
3630
+ prepend ? [listener, existing] : [existing, listener];
3631
+ // If we've already got an array, just append.
3632
+ } else if (prepend) {
3633
+ existing.unshift(listener);
3634
+ } else {
3635
+ existing.push(listener);
3636
+ }
3637
+
3638
+ // Check for listener leak
3639
+ m = _getMaxListeners(target);
3640
+ if (m > 0 && existing.length > m && !existing.warned) {
3641
+ existing.warned = true;
3642
+ // No error code for this since it is a Warning
3643
+ // eslint-disable-next-line no-restricted-syntax
3644
+ var w = new Error('Possible EventEmitter memory leak detected. ' +
3645
+ existing.length + ' ' + String(type) + ' listeners ' +
3646
+ 'added. Use emitter.setMaxListeners() to ' +
3647
+ 'increase limit');
3648
+ w.name = 'MaxListenersExceededWarning';
3649
+ w.emitter = target;
3650
+ w.type = type;
3651
+ w.count = existing.length;
3652
+ ProcessEmitWarning(w);
3653
+ }
3654
+ }
3655
+
3656
+ return target;
3657
+ }
3658
+
3659
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
3660
+ return _addListener(this, type, listener, false);
3661
+ };
3662
+
3663
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
3664
+
3665
+ EventEmitter.prototype.prependListener =
3666
+ function prependListener(type, listener) {
3667
+ return _addListener(this, type, listener, true);
3668
+ };
3669
+
3670
+ function onceWrapper() {
3671
+ if (!this.fired) {
3672
+ this.target.removeListener(this.type, this.wrapFn);
3673
+ this.fired = true;
3674
+ if (arguments.length === 0)
3675
+ return this.listener.call(this.target);
3676
+ return this.listener.apply(this.target, arguments);
3677
+ }
3678
+ }
3679
+
3680
+ function _onceWrap(target, type, listener) {
3681
+ var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
3682
+ var wrapped = onceWrapper.bind(state);
3683
+ wrapped.listener = listener;
3684
+ state.wrapFn = wrapped;
3685
+ return wrapped;
3686
+ }
3687
+
3688
+ EventEmitter.prototype.once = function once(type, listener) {
3689
+ checkListener(listener);
3690
+ this.on(type, _onceWrap(this, type, listener));
3691
+ return this;
3692
+ };
3693
+
3694
+ EventEmitter.prototype.prependOnceListener =
3695
+ function prependOnceListener(type, listener) {
3696
+ checkListener(listener);
3697
+ this.prependListener(type, _onceWrap(this, type, listener));
3698
+ return this;
3699
+ };
3700
+
3701
+ // Emits a 'removeListener' event if and only if the listener was removed.
3702
+ EventEmitter.prototype.removeListener =
3703
+ function removeListener(type, listener) {
3704
+ var list, events, position, i, originalListener;
3705
+
3706
+ checkListener(listener);
3707
+
3708
+ events = this._events;
3709
+ if (events === undefined)
3710
+ return this;
3711
+
3712
+ list = events[type];
3713
+ if (list === undefined)
3714
+ return this;
3715
+
3716
+ if (list === listener || list.listener === listener) {
3717
+ if (--this._eventsCount === 0)
3718
+ this._events = Object.create(null);
3719
+ else {
3720
+ delete events[type];
3721
+ if (events.removeListener)
3722
+ this.emit('removeListener', type, list.listener || listener);
3723
+ }
3724
+ } else if (typeof list !== 'function') {
3725
+ position = -1;
3726
+
3727
+ for (i = list.length - 1; i >= 0; i--) {
3728
+ if (list[i] === listener || list[i].listener === listener) {
3729
+ originalListener = list[i].listener;
3730
+ position = i;
3731
+ break;
3732
+ }
3733
+ }
3734
+
3735
+ if (position < 0)
3736
+ return this;
3737
+
3738
+ if (position === 0)
3739
+ list.shift();
3740
+ else {
3741
+ spliceOne(list, position);
3742
+ }
3743
+
3744
+ if (list.length === 1)
3745
+ events[type] = list[0];
3746
+
3747
+ if (events.removeListener !== undefined)
3748
+ this.emit('removeListener', type, originalListener || listener);
3749
+ }
3750
+
3751
+ return this;
3752
+ };
3753
+
3754
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
3755
+
3756
+ EventEmitter.prototype.removeAllListeners =
3757
+ function removeAllListeners(type) {
3758
+ var listeners, events, i;
3759
+
3760
+ events = this._events;
3761
+ if (events === undefined)
3762
+ return this;
3763
+
3764
+ // not listening for removeListener, no need to emit
3765
+ if (events.removeListener === undefined) {
3766
+ if (arguments.length === 0) {
3767
+ this._events = Object.create(null);
3768
+ this._eventsCount = 0;
3769
+ } else if (events[type] !== undefined) {
3770
+ if (--this._eventsCount === 0)
3771
+ this._events = Object.create(null);
3772
+ else
3773
+ delete events[type];
3774
+ }
3775
+ return this;
3776
+ }
3777
+
3778
+ // emit removeListener for all listeners on all events
3779
+ if (arguments.length === 0) {
3780
+ var keys = Object.keys(events);
3781
+ var key;
3782
+ for (i = 0; i < keys.length; ++i) {
3783
+ key = keys[i];
3784
+ if (key === 'removeListener') continue;
3785
+ this.removeAllListeners(key);
3786
+ }
3787
+ this.removeAllListeners('removeListener');
3788
+ this._events = Object.create(null);
3789
+ this._eventsCount = 0;
3790
+ return this;
3791
+ }
3792
+
3793
+ listeners = events[type];
3794
+
3795
+ if (typeof listeners === 'function') {
3796
+ this.removeListener(type, listeners);
3797
+ } else if (listeners !== undefined) {
3798
+ // LIFO order
3799
+ for (i = listeners.length - 1; i >= 0; i--) {
3800
+ this.removeListener(type, listeners[i]);
3801
+ }
3802
+ }
3803
+
3804
+ return this;
3805
+ };
3806
+
3807
+ function _listeners(target, type, unwrap) {
3808
+ var events = target._events;
3809
+
3810
+ if (events === undefined)
3811
+ return [];
3812
+
3813
+ var evlistener = events[type];
3814
+ if (evlistener === undefined)
3815
+ return [];
3816
+
3817
+ if (typeof evlistener === 'function')
3818
+ return unwrap ? [evlistener.listener || evlistener] : [evlistener];
3819
+
3820
+ return unwrap ?
3821
+ unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
3822
+ }
3823
+
3824
+ EventEmitter.prototype.listeners = function listeners(type) {
3825
+ return _listeners(this, type, true);
3826
+ };
3827
+
3828
+ EventEmitter.prototype.rawListeners = function rawListeners(type) {
3829
+ return _listeners(this, type, false);
3830
+ };
3831
+
3832
+ EventEmitter.listenerCount = function(emitter, type) {
3833
+ if (typeof emitter.listenerCount === 'function') {
3834
+ return emitter.listenerCount(type);
3835
+ } else {
3836
+ return listenerCount.call(emitter, type);
3837
+ }
3838
+ };
3839
+
3840
+ EventEmitter.prototype.listenerCount = listenerCount;
3841
+ function listenerCount(type) {
3842
+ var events = this._events;
3843
+
3844
+ if (events !== undefined) {
3845
+ var evlistener = events[type];
3846
+
3847
+ if (typeof evlistener === 'function') {
3848
+ return 1;
3849
+ } else if (evlistener !== undefined) {
3850
+ return evlistener.length;
3851
+ }
3852
+ }
3853
+
3854
+ return 0;
3855
+ }
3856
+
3857
+ EventEmitter.prototype.eventNames = function eventNames() {
3858
+ return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
3859
+ };
3860
+
3861
+ function arrayClone(arr, n) {
3862
+ var copy = new Array(n);
3863
+ for (var i = 0; i < n; ++i)
3864
+ copy[i] = arr[i];
3865
+ return copy;
3866
+ }
3867
+
3868
+ function spliceOne(list, index) {
3869
+ for (; index + 1 < list.length; index++)
3870
+ list[index] = list[index + 1];
3871
+ list.pop();
3872
+ }
3873
+
3874
+ function unwrapListeners(arr) {
3875
+ var ret = new Array(arr.length);
3876
+ for (var i = 0; i < ret.length; ++i) {
3877
+ ret[i] = arr[i].listener || arr[i];
3878
+ }
3879
+ return ret;
3880
+ }
3881
+
3882
+ function once$2(emitter, name) {
3883
+ return new Promise(function (resolve, reject) {
3884
+ function errorListener(err) {
3885
+ emitter.removeListener(name, resolver);
3886
+ reject(err);
3887
+ }
3888
+
3889
+ function resolver() {
3890
+ if (typeof emitter.removeListener === 'function') {
3891
+ emitter.removeListener('error', errorListener);
3892
+ }
3893
+ resolve([].slice.call(arguments));
3894
+ }
3895
+ eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
3896
+ if (name !== 'error') {
3897
+ addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
3898
+ }
3899
+ });
3900
+ }
3901
+
3902
+ function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
3903
+ if (typeof emitter.on === 'function') {
3904
+ eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
3905
+ }
3906
+ }
3907
+
3908
+ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
3909
+ if (typeof emitter.on === 'function') {
3910
+ if (flags.once) {
3911
+ emitter.once(name, listener);
3912
+ } else {
3913
+ emitter.on(name, listener);
3914
+ }
3915
+ } else if (typeof emitter.addEventListener === 'function') {
3916
+ // EventTarget does not have `error` event semantics like Node
3917
+ // EventEmitters, we do not listen for `error` events here.
3918
+ emitter.addEventListener(name, function wrapListener(arg) {
3919
+ // IE does not have builtin `{ once: true }` support so we
3920
+ // have to do it manually.
3921
+ if (flags.once) {
3922
+ emitter.removeEventListener(name, wrapListener);
3923
+ }
3924
+ listener(arg);
3925
+ });
3926
+ } else {
3927
+ throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
3928
+ }
3929
+ }
3930
+
3931
+ var streamBrowser = eventsExports.EventEmitter;
1105
3932
 
1106
3933
  var buffer_list;
1107
3934
  var hasRequiredBuffer_list;
@@ -1115,7 +3942,7 @@ function requireBuffer_list () {
1115
3942
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1116
3943
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
1117
3944
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1118
- const _require = require$$0,
3945
+ const _require = buffer,
1119
3946
  Buffer = _require.Buffer;
1120
3947
  const _require2 = require$$3,
1121
3948
  inspect = _require2.inspect;
@@ -1612,7 +4439,7 @@ function require_stream_writable () {
1612
4439
  var Stream = streamBrowser;
1613
4440
  /*</replacement>*/
1614
4441
 
1615
- const Buffer = require$$0.Buffer;
4442
+ const Buffer = buffer.Buffer;
1616
4443
  const OurUint8Array = (typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
1617
4444
  function _uint8ArrayToBuffer(chunk) {
1618
4445
  return Buffer.from(chunk);
@@ -2885,7 +5712,7 @@ function require_stream_readable () {
2885
5712
  Readable.ReadableState = ReadableState;
2886
5713
 
2887
5714
  /*<replacement>*/
2888
- require$$0$1.EventEmitter;
5715
+ eventsExports.EventEmitter;
2889
5716
  var EElistenerCount = function EElistenerCount(emitter, type) {
2890
5717
  return emitter.listeners(type).length;
2891
5718
  };
@@ -2895,7 +5722,7 @@ function require_stream_readable () {
2895
5722
  var Stream = streamBrowser;
2896
5723
  /*</replacement>*/
2897
5724
 
2898
- const Buffer = require$$0.Buffer;
5725
+ const Buffer = buffer.Buffer;
2899
5726
  const OurUint8Array = (typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
2900
5727
  function _uint8ArrayToBuffer(chunk) {
2901
5728
  return Buffer.from(chunk);
@@ -4199,7 +7026,7 @@ const randombytes = browserExports;
4199
7026
  const stream = readableBrowserExports;
4200
7027
  const queueMicrotask$1 = queueMicrotask_1; // TODO: remove when Node 10 is not supported
4201
7028
  const errCode = errCode$1;
4202
- const { Buffer } = require$$0;
7029
+ const { Buffer } = buffer;
4203
7030
 
4204
7031
  const MAX_BUFFERED_AMOUNT = 64 * 1024;
4205
7032
  const ICECOMPLETE_TIMEOUT = 5 * 1000;