contentful-management 11.64.0-new-beta.4 → 11.64.0-new-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +46 -28
  2. package/dist/browser/index.js +29 -1990
  3. package/dist/browser/index.js.map +1 -1
  4. package/dist/browser/index.min.js +1 -1
  5. package/dist/browser/index.min.js.map +1 -1
  6. package/dist/cjs/index.cjs +1 -4
  7. package/dist/cjs/index.cjs.map +1 -1
  8. package/dist/esm/adapters/REST/endpoints/app-upload.mjs.map +1 -1
  9. package/dist/esm/adapters/REST/endpoints/upload.mjs.map +1 -1
  10. package/dist/esm/adapters/REST/rest-adapter.mjs +0 -2
  11. package/dist/esm/adapters/REST/rest-adapter.mjs.map +1 -1
  12. package/dist/esm/common-types.mjs.map +1 -1
  13. package/dist/esm/create-environment-api.mjs.map +1 -1
  14. package/dist/esm/create-organization-api.mjs.map +1 -1
  15. package/dist/esm/entities/asset.mjs.map +1 -1
  16. package/dist/esm/index.mjs +1 -1
  17. package/dist/esm/methods/action.mjs +0 -1
  18. package/dist/esm/methods/action.mjs.map +1 -1
  19. package/dist/types/adapters/REST/endpoints/app-upload.js.map +1 -1
  20. package/dist/types/adapters/REST/endpoints/upload.js.map +1 -1
  21. package/dist/types/adapters/REST/rest-adapter.js +0 -2
  22. package/dist/types/adapters/REST/rest-adapter.js.map +1 -1
  23. package/dist/types/common-types.d.ts +2 -3
  24. package/dist/types/common-types.js.map +1 -1
  25. package/dist/types/create-environment-api.d.ts +1 -2
  26. package/dist/types/create-environment-api.js.map +1 -1
  27. package/dist/types/create-organization-api.d.ts +1 -2
  28. package/dist/types/create-organization-api.js.map +1 -1
  29. package/dist/types/entities/asset.d.ts +1 -2
  30. package/dist/types/entities/asset.js.map +1 -1
  31. package/dist/types/index.js +1 -1
  32. package/dist/types/methods/action.js +0 -1
  33. package/dist/types/methods/action.js.map +1 -1
  34. package/dist/types/plain/entities/app-upload.d.ts +1 -2
  35. package/dist/types/plain/entities/upload.d.ts +1 -2
  36. package/package.json +5 -5
@@ -285,7 +285,7 @@ var contentfulManagement = (function (exports) {
285
285
  return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);
286
286
  }
287
287
 
288
- var isArray$2 = Array.isArray;
288
+ var isArray$1 = Array.isArray;
289
289
  var assign = Object.assign;
290
290
  var getPrototypeOf = Object.getPrototypeOf || (function (obj) { return obj.__proto__; });
291
291
  var DEFAULT_LOOSE_OPTIONS = {
@@ -362,7 +362,7 @@ var contentfulManagement = (function (exports) {
362
362
  return object(value, state);
363
363
  }
364
364
  // arrays
365
- if (isArray$2(value)) {
365
+ if (isArray$1(value)) {
366
366
  return array(value, state);
367
367
  }
368
368
  var tagSpecificCopier = tagSpecificCopiers[getTag(value)];
@@ -706,9 +706,7 @@ var contentfulManagement = (function (exports) {
706
706
  });
707
707
  }
708
708
 
709
- var global$1 = (typeof global !== "undefined" ? global :
710
- typeof self !== "undefined" ? self :
711
- typeof window !== "undefined" ? window : {});
709
+ /** Detect free variable `global` from Node.js. */
712
710
 
713
711
  var _freeGlobal;
714
712
  var hasRequired_freeGlobal;
@@ -716,7 +714,7 @@ var contentfulManagement = (function (exports) {
716
714
  function require_freeGlobal () {
717
715
  if (hasRequired_freeGlobal) return _freeGlobal;
718
716
  hasRequired_freeGlobal = 1;
719
- var freeGlobal = typeof global$1 == 'object' && global$1 && global$1.Object === Object && global$1;
717
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
720
718
 
721
719
  _freeGlobal = freeGlobal;
722
720
  return _freeGlobal;
@@ -1157,1983 +1155,6 @@ var contentfulManagement = (function (exports) {
1157
1155
  return type;
1158
1156
  }
1159
1157
 
1160
- var lookup = [];
1161
- var revLookup = [];
1162
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
1163
- var inited = false;
1164
- function init () {
1165
- inited = true;
1166
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1167
- for (var i = 0, len = code.length; i < len; ++i) {
1168
- lookup[i] = code[i];
1169
- revLookup[code.charCodeAt(i)] = i;
1170
- }
1171
-
1172
- revLookup['-'.charCodeAt(0)] = 62;
1173
- revLookup['_'.charCodeAt(0)] = 63;
1174
- }
1175
-
1176
- function toByteArray (b64) {
1177
- if (!inited) {
1178
- init();
1179
- }
1180
- var i, j, l, tmp, placeHolders, arr;
1181
- var len = b64.length;
1182
-
1183
- if (len % 4 > 0) {
1184
- throw new Error('Invalid string. Length must be a multiple of 4')
1185
- }
1186
-
1187
- // the number of equal signs (place holders)
1188
- // if there are two placeholders, than the two characters before it
1189
- // represent one byte
1190
- // if there is only one, then the three characters before it represent 2 bytes
1191
- // this is just a cheap hack to not do indexOf twice
1192
- placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0;
1193
-
1194
- // base64 is 4/3 + up to two characters of the original data
1195
- arr = new Arr(len * 3 / 4 - placeHolders);
1196
-
1197
- // if there are placeholders, only get up to the last complete 4 chars
1198
- l = placeHolders > 0 ? len - 4 : len;
1199
-
1200
- var L = 0;
1201
-
1202
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
1203
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)];
1204
- arr[L++] = (tmp >> 16) & 0xFF;
1205
- arr[L++] = (tmp >> 8) & 0xFF;
1206
- arr[L++] = tmp & 0xFF;
1207
- }
1208
-
1209
- if (placeHolders === 2) {
1210
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4);
1211
- arr[L++] = tmp & 0xFF;
1212
- } else if (placeHolders === 1) {
1213
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2);
1214
- arr[L++] = (tmp >> 8) & 0xFF;
1215
- arr[L++] = tmp & 0xFF;
1216
- }
1217
-
1218
- return arr
1219
- }
1220
-
1221
- function tripletToBase64 (num) {
1222
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
1223
- }
1224
-
1225
- function encodeChunk (uint8, start, end) {
1226
- var tmp;
1227
- var output = [];
1228
- for (var i = start; i < end; i += 3) {
1229
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);
1230
- output.push(tripletToBase64(tmp));
1231
- }
1232
- return output.join('')
1233
- }
1234
-
1235
- function fromByteArray (uint8) {
1236
- if (!inited) {
1237
- init();
1238
- }
1239
- var tmp;
1240
- var len = uint8.length;
1241
- var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
1242
- var output = '';
1243
- var parts = [];
1244
- var maxChunkLength = 16383; // must be multiple of 3
1245
-
1246
- // go through the array every three bytes, we'll deal with trailing stuff later
1247
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
1248
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)));
1249
- }
1250
-
1251
- // pad the end with zeros, but make sure to not forget the extra bytes
1252
- if (extraBytes === 1) {
1253
- tmp = uint8[len - 1];
1254
- output += lookup[tmp >> 2];
1255
- output += lookup[(tmp << 4) & 0x3F];
1256
- output += '==';
1257
- } else if (extraBytes === 2) {
1258
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1]);
1259
- output += lookup[tmp >> 10];
1260
- output += lookup[(tmp >> 4) & 0x3F];
1261
- output += lookup[(tmp << 2) & 0x3F];
1262
- output += '=';
1263
- }
1264
-
1265
- parts.push(output);
1266
-
1267
- return parts.join('')
1268
- }
1269
-
1270
- function read (buffer, offset, isLE, mLen, nBytes) {
1271
- var e, m;
1272
- var eLen = nBytes * 8 - mLen - 1;
1273
- var eMax = (1 << eLen) - 1;
1274
- var eBias = eMax >> 1;
1275
- var nBits = -7;
1276
- var i = isLE ? (nBytes - 1) : 0;
1277
- var d = isLE ? -1 : 1;
1278
- var s = buffer[offset + i];
1279
-
1280
- i += d;
1281
-
1282
- e = s & ((1 << (-nBits)) - 1);
1283
- s >>= (-nBits);
1284
- nBits += eLen;
1285
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
1286
-
1287
- m = e & ((1 << (-nBits)) - 1);
1288
- e >>= (-nBits);
1289
- nBits += mLen;
1290
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
1291
-
1292
- if (e === 0) {
1293
- e = 1 - eBias;
1294
- } else if (e === eMax) {
1295
- return m ? NaN : ((s ? -1 : 1) * Infinity)
1296
- } else {
1297
- m = m + Math.pow(2, mLen);
1298
- e = e - eBias;
1299
- }
1300
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
1301
- }
1302
-
1303
- function write (buffer, value, offset, isLE, mLen, nBytes) {
1304
- var e, m, c;
1305
- var eLen = nBytes * 8 - mLen - 1;
1306
- var eMax = (1 << eLen) - 1;
1307
- var eBias = eMax >> 1;
1308
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
1309
- var i = isLE ? 0 : (nBytes - 1);
1310
- var d = isLE ? 1 : -1;
1311
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
1312
-
1313
- value = Math.abs(value);
1314
-
1315
- if (isNaN(value) || value === Infinity) {
1316
- m = isNaN(value) ? 1 : 0;
1317
- e = eMax;
1318
- } else {
1319
- e = Math.floor(Math.log(value) / Math.LN2);
1320
- if (value * (c = Math.pow(2, -e)) < 1) {
1321
- e--;
1322
- c *= 2;
1323
- }
1324
- if (e + eBias >= 1) {
1325
- value += rt / c;
1326
- } else {
1327
- value += rt * Math.pow(2, 1 - eBias);
1328
- }
1329
- if (value * c >= 2) {
1330
- e++;
1331
- c /= 2;
1332
- }
1333
-
1334
- if (e + eBias >= eMax) {
1335
- m = 0;
1336
- e = eMax;
1337
- } else if (e + eBias >= 1) {
1338
- m = (value * c - 1) * Math.pow(2, mLen);
1339
- e = e + eBias;
1340
- } else {
1341
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
1342
- e = 0;
1343
- }
1344
- }
1345
-
1346
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
1347
-
1348
- e = (e << mLen) | m;
1349
- eLen += mLen;
1350
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
1351
-
1352
- buffer[offset + i - d] |= s * 128;
1353
- }
1354
-
1355
- var toString = {}.toString;
1356
-
1357
- var isArray$1 = Array.isArray || function (arr) {
1358
- return toString.call(arr) == '[object Array]';
1359
- };
1360
-
1361
- /*!
1362
- * The buffer module from node.js, for the browser.
1363
- *
1364
- * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
1365
- * @license MIT
1366
- */
1367
- /* eslint-disable no-proto */
1368
-
1369
-
1370
- var INSPECT_MAX_BYTES = 50;
1371
-
1372
- /**
1373
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
1374
- * === true Use Uint8Array implementation (fastest)
1375
- * === false Use Object implementation (most compatible, even IE6)
1376
- *
1377
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
1378
- * Opera 11.6+, iOS 4.2+.
1379
- *
1380
- * Due to various browser bugs, sometimes the Object implementation will be used even
1381
- * when the browser supports typed arrays.
1382
- *
1383
- * Note:
1384
- *
1385
- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
1386
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
1387
- *
1388
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
1389
- *
1390
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
1391
- * incorrect length in some situations.
1392
-
1393
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
1394
- * get the Object implementation, which is slower but behaves correctly.
1395
- */
1396
- Buffer$1.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== undefined
1397
- ? global$1.TYPED_ARRAY_SUPPORT
1398
- : true;
1399
-
1400
- /*
1401
- * Export kMaxLength after typed array support is determined.
1402
- */
1403
- kMaxLength();
1404
-
1405
- function kMaxLength () {
1406
- return Buffer$1.TYPED_ARRAY_SUPPORT
1407
- ? 0x7fffffff
1408
- : 0x3fffffff
1409
- }
1410
-
1411
- function createBuffer (that, length) {
1412
- if (kMaxLength() < length) {
1413
- throw new RangeError('Invalid typed array length')
1414
- }
1415
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
1416
- // Return an augmented `Uint8Array` instance, for best performance
1417
- that = new Uint8Array(length);
1418
- that.__proto__ = Buffer$1.prototype;
1419
- } else {
1420
- // Fallback: Return an object instance of the Buffer class
1421
- if (that === null) {
1422
- that = new Buffer$1(length);
1423
- }
1424
- that.length = length;
1425
- }
1426
-
1427
- return that
1428
- }
1429
-
1430
- /**
1431
- * The Buffer constructor returns instances of `Uint8Array` that have their
1432
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
1433
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
1434
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
1435
- * returns a single octet.
1436
- *
1437
- * The `Uint8Array` prototype remains unmodified.
1438
- */
1439
-
1440
- function Buffer$1 (arg, encodingOrOffset, length) {
1441
- if (!Buffer$1.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer$1)) {
1442
- return new Buffer$1(arg, encodingOrOffset, length)
1443
- }
1444
-
1445
- // Common case.
1446
- if (typeof arg === 'number') {
1447
- if (typeof encodingOrOffset === 'string') {
1448
- throw new Error(
1449
- 'If encoding is specified then the first argument must be a string'
1450
- )
1451
- }
1452
- return allocUnsafe(this, arg)
1453
- }
1454
- return from(this, arg, encodingOrOffset, length)
1455
- }
1456
-
1457
- Buffer$1.poolSize = 8192; // not used by this implementation
1458
-
1459
- // TODO: Legacy, not needed anymore. Remove in next major version.
1460
- Buffer$1._augment = function (arr) {
1461
- arr.__proto__ = Buffer$1.prototype;
1462
- return arr
1463
- };
1464
-
1465
- function from (that, value, encodingOrOffset, length) {
1466
- if (typeof value === 'number') {
1467
- throw new TypeError('"value" argument must not be a number')
1468
- }
1469
-
1470
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
1471
- return fromArrayBuffer(that, value, encodingOrOffset, length)
1472
- }
1473
-
1474
- if (typeof value === 'string') {
1475
- return fromString(that, value, encodingOrOffset)
1476
- }
1477
-
1478
- return fromObject(that, value)
1479
- }
1480
-
1481
- /**
1482
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
1483
- * if value is a number.
1484
- * Buffer.from(str[, encoding])
1485
- * Buffer.from(array)
1486
- * Buffer.from(buffer)
1487
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
1488
- **/
1489
- Buffer$1.from = function (value, encodingOrOffset, length) {
1490
- return from(null, value, encodingOrOffset, length)
1491
- };
1492
-
1493
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
1494
- Buffer$1.prototype.__proto__ = Uint8Array.prototype;
1495
- Buffer$1.__proto__ = Uint8Array;
1496
- if (typeof Symbol !== 'undefined' && Symbol.species &&
1497
- Buffer$1[Symbol.species] === Buffer$1) ;
1498
- }
1499
-
1500
- function assertSize (size) {
1501
- if (typeof size !== 'number') {
1502
- throw new TypeError('"size" argument must be a number')
1503
- } else if (size < 0) {
1504
- throw new RangeError('"size" argument must not be negative')
1505
- }
1506
- }
1507
-
1508
- function alloc (that, size, fill, encoding) {
1509
- assertSize(size);
1510
- if (size <= 0) {
1511
- return createBuffer(that, size)
1512
- }
1513
- if (fill !== undefined) {
1514
- // Only pay attention to encoding if it's a string. This
1515
- // prevents accidentally sending in a number that would
1516
- // be interpretted as a start offset.
1517
- return typeof encoding === 'string'
1518
- ? createBuffer(that, size).fill(fill, encoding)
1519
- : createBuffer(that, size).fill(fill)
1520
- }
1521
- return createBuffer(that, size)
1522
- }
1523
-
1524
- /**
1525
- * Creates a new filled Buffer instance.
1526
- * alloc(size[, fill[, encoding]])
1527
- **/
1528
- Buffer$1.alloc = function (size, fill, encoding) {
1529
- return alloc(null, size, fill, encoding)
1530
- };
1531
-
1532
- function allocUnsafe (that, size) {
1533
- assertSize(size);
1534
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
1535
- if (!Buffer$1.TYPED_ARRAY_SUPPORT) {
1536
- for (var i = 0; i < size; ++i) {
1537
- that[i] = 0;
1538
- }
1539
- }
1540
- return that
1541
- }
1542
-
1543
- /**
1544
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
1545
- * */
1546
- Buffer$1.allocUnsafe = function (size) {
1547
- return allocUnsafe(null, size)
1548
- };
1549
- /**
1550
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
1551
- */
1552
- Buffer$1.allocUnsafeSlow = function (size) {
1553
- return allocUnsafe(null, size)
1554
- };
1555
-
1556
- function fromString (that, string, encoding) {
1557
- if (typeof encoding !== 'string' || encoding === '') {
1558
- encoding = 'utf8';
1559
- }
1560
-
1561
- if (!Buffer$1.isEncoding(encoding)) {
1562
- throw new TypeError('"encoding" must be a valid string encoding')
1563
- }
1564
-
1565
- var length = byteLength(string, encoding) | 0;
1566
- that = createBuffer(that, length);
1567
-
1568
- var actual = that.write(string, encoding);
1569
-
1570
- if (actual !== length) {
1571
- // Writing a hex string, for example, that contains invalid characters will
1572
- // cause everything after the first invalid character to be ignored. (e.g.
1573
- // 'abxxcd' will be treated as 'ab')
1574
- that = that.slice(0, actual);
1575
- }
1576
-
1577
- return that
1578
- }
1579
-
1580
- function fromArrayLike (that, array) {
1581
- var length = array.length < 0 ? 0 : checked(array.length) | 0;
1582
- that = createBuffer(that, length);
1583
- for (var i = 0; i < length; i += 1) {
1584
- that[i] = array[i] & 255;
1585
- }
1586
- return that
1587
- }
1588
-
1589
- function fromArrayBuffer (that, array, byteOffset, length) {
1590
- array.byteLength; // this throws if `array` is not a valid ArrayBuffer
1591
-
1592
- if (byteOffset < 0 || array.byteLength < byteOffset) {
1593
- throw new RangeError('\'offset\' is out of bounds')
1594
- }
1595
-
1596
- if (array.byteLength < byteOffset + (length || 0)) {
1597
- throw new RangeError('\'length\' is out of bounds')
1598
- }
1599
-
1600
- if (byteOffset === undefined && length === undefined) {
1601
- array = new Uint8Array(array);
1602
- } else if (length === undefined) {
1603
- array = new Uint8Array(array, byteOffset);
1604
- } else {
1605
- array = new Uint8Array(array, byteOffset, length);
1606
- }
1607
-
1608
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
1609
- // Return an augmented `Uint8Array` instance, for best performance
1610
- that = array;
1611
- that.__proto__ = Buffer$1.prototype;
1612
- } else {
1613
- // Fallback: Return an object instance of the Buffer class
1614
- that = fromArrayLike(that, array);
1615
- }
1616
- return that
1617
- }
1618
-
1619
- function fromObject (that, obj) {
1620
- if (internalIsBuffer(obj)) {
1621
- var len = checked(obj.length) | 0;
1622
- that = createBuffer(that, len);
1623
-
1624
- if (that.length === 0) {
1625
- return that
1626
- }
1627
-
1628
- obj.copy(that, 0, 0, len);
1629
- return that
1630
- }
1631
-
1632
- if (obj) {
1633
- if ((typeof ArrayBuffer !== 'undefined' &&
1634
- obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
1635
- if (typeof obj.length !== 'number' || isnan(obj.length)) {
1636
- return createBuffer(that, 0)
1637
- }
1638
- return fromArrayLike(that, obj)
1639
- }
1640
-
1641
- if (obj.type === 'Buffer' && isArray$1(obj.data)) {
1642
- return fromArrayLike(that, obj.data)
1643
- }
1644
- }
1645
-
1646
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
1647
- }
1648
-
1649
- function checked (length) {
1650
- // Note: cannot use `length < kMaxLength()` here because that fails when
1651
- // length is NaN (which is otherwise coerced to zero.)
1652
- if (length >= kMaxLength()) {
1653
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
1654
- 'size: 0x' + kMaxLength().toString(16) + ' bytes')
1655
- }
1656
- return length | 0
1657
- }
1658
- Buffer$1.isBuffer = isBuffer$1;
1659
- function internalIsBuffer (b) {
1660
- return !!(b != null && b._isBuffer)
1661
- }
1662
-
1663
- Buffer$1.compare = function compare (a, b) {
1664
- if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
1665
- throw new TypeError('Arguments must be Buffers')
1666
- }
1667
-
1668
- if (a === b) return 0
1669
-
1670
- var x = a.length;
1671
- var y = b.length;
1672
-
1673
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
1674
- if (a[i] !== b[i]) {
1675
- x = a[i];
1676
- y = b[i];
1677
- break
1678
- }
1679
- }
1680
-
1681
- if (x < y) return -1
1682
- if (y < x) return 1
1683
- return 0
1684
- };
1685
-
1686
- Buffer$1.isEncoding = function isEncoding (encoding) {
1687
- switch (String(encoding).toLowerCase()) {
1688
- case 'hex':
1689
- case 'utf8':
1690
- case 'utf-8':
1691
- case 'ascii':
1692
- case 'latin1':
1693
- case 'binary':
1694
- case 'base64':
1695
- case 'ucs2':
1696
- case 'ucs-2':
1697
- case 'utf16le':
1698
- case 'utf-16le':
1699
- return true
1700
- default:
1701
- return false
1702
- }
1703
- };
1704
-
1705
- Buffer$1.concat = function concat (list, length) {
1706
- if (!isArray$1(list)) {
1707
- throw new TypeError('"list" argument must be an Array of Buffers')
1708
- }
1709
-
1710
- if (list.length === 0) {
1711
- return Buffer$1.alloc(0)
1712
- }
1713
-
1714
- var i;
1715
- if (length === undefined) {
1716
- length = 0;
1717
- for (i = 0; i < list.length; ++i) {
1718
- length += list[i].length;
1719
- }
1720
- }
1721
-
1722
- var buffer = Buffer$1.allocUnsafe(length);
1723
- var pos = 0;
1724
- for (i = 0; i < list.length; ++i) {
1725
- var buf = list[i];
1726
- if (!internalIsBuffer(buf)) {
1727
- throw new TypeError('"list" argument must be an Array of Buffers')
1728
- }
1729
- buf.copy(buffer, pos);
1730
- pos += buf.length;
1731
- }
1732
- return buffer
1733
- };
1734
-
1735
- function byteLength (string, encoding) {
1736
- if (internalIsBuffer(string)) {
1737
- return string.length
1738
- }
1739
- if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
1740
- (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
1741
- return string.byteLength
1742
- }
1743
- if (typeof string !== 'string') {
1744
- string = '' + string;
1745
- }
1746
-
1747
- var len = string.length;
1748
- if (len === 0) return 0
1749
-
1750
- // Use a for loop to avoid recursion
1751
- var loweredCase = false;
1752
- for (;;) {
1753
- switch (encoding) {
1754
- case 'ascii':
1755
- case 'latin1':
1756
- case 'binary':
1757
- return len
1758
- case 'utf8':
1759
- case 'utf-8':
1760
- case undefined:
1761
- return utf8ToBytes(string).length
1762
- case 'ucs2':
1763
- case 'ucs-2':
1764
- case 'utf16le':
1765
- case 'utf-16le':
1766
- return len * 2
1767
- case 'hex':
1768
- return len >>> 1
1769
- case 'base64':
1770
- return base64ToBytes(string).length
1771
- default:
1772
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
1773
- encoding = ('' + encoding).toLowerCase();
1774
- loweredCase = true;
1775
- }
1776
- }
1777
- }
1778
- Buffer$1.byteLength = byteLength;
1779
-
1780
- function slowToString (encoding, start, end) {
1781
- var loweredCase = false;
1782
-
1783
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1784
- // property of a typed array.
1785
-
1786
- // This behaves neither like String nor Uint8Array in that we set start/end
1787
- // to their upper/lower bounds if the value passed is out of range.
1788
- // undefined is handled specially as per ECMA-262 6th Edition,
1789
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1790
- if (start === undefined || start < 0) {
1791
- start = 0;
1792
- }
1793
- // Return early if start > this.length. Done here to prevent potential uint32
1794
- // coercion fail below.
1795
- if (start > this.length) {
1796
- return ''
1797
- }
1798
-
1799
- if (end === undefined || end > this.length) {
1800
- end = this.length;
1801
- }
1802
-
1803
- if (end <= 0) {
1804
- return ''
1805
- }
1806
-
1807
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
1808
- end >>>= 0;
1809
- start >>>= 0;
1810
-
1811
- if (end <= start) {
1812
- return ''
1813
- }
1814
-
1815
- if (!encoding) encoding = 'utf8';
1816
-
1817
- while (true) {
1818
- switch (encoding) {
1819
- case 'hex':
1820
- return hexSlice(this, start, end)
1821
-
1822
- case 'utf8':
1823
- case 'utf-8':
1824
- return utf8Slice(this, start, end)
1825
-
1826
- case 'ascii':
1827
- return asciiSlice(this, start, end)
1828
-
1829
- case 'latin1':
1830
- case 'binary':
1831
- return latin1Slice(this, start, end)
1832
-
1833
- case 'base64':
1834
- return base64Slice(this, start, end)
1835
-
1836
- case 'ucs2':
1837
- case 'ucs-2':
1838
- case 'utf16le':
1839
- case 'utf-16le':
1840
- return utf16leSlice(this, start, end)
1841
-
1842
- default:
1843
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1844
- encoding = (encoding + '').toLowerCase();
1845
- loweredCase = true;
1846
- }
1847
- }
1848
- }
1849
-
1850
- // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
1851
- // Buffer instances.
1852
- Buffer$1.prototype._isBuffer = true;
1853
-
1854
- function swap (b, n, m) {
1855
- var i = b[n];
1856
- b[n] = b[m];
1857
- b[m] = i;
1858
- }
1859
-
1860
- Buffer$1.prototype.swap16 = function swap16 () {
1861
- var len = this.length;
1862
- if (len % 2 !== 0) {
1863
- throw new RangeError('Buffer size must be a multiple of 16-bits')
1864
- }
1865
- for (var i = 0; i < len; i += 2) {
1866
- swap(this, i, i + 1);
1867
- }
1868
- return this
1869
- };
1870
-
1871
- Buffer$1.prototype.swap32 = function swap32 () {
1872
- var len = this.length;
1873
- if (len % 4 !== 0) {
1874
- throw new RangeError('Buffer size must be a multiple of 32-bits')
1875
- }
1876
- for (var i = 0; i < len; i += 4) {
1877
- swap(this, i, i + 3);
1878
- swap(this, i + 1, i + 2);
1879
- }
1880
- return this
1881
- };
1882
-
1883
- Buffer$1.prototype.swap64 = function swap64 () {
1884
- var len = this.length;
1885
- if (len % 8 !== 0) {
1886
- throw new RangeError('Buffer size must be a multiple of 64-bits')
1887
- }
1888
- for (var i = 0; i < len; i += 8) {
1889
- swap(this, i, i + 7);
1890
- swap(this, i + 1, i + 6);
1891
- swap(this, i + 2, i + 5);
1892
- swap(this, i + 3, i + 4);
1893
- }
1894
- return this
1895
- };
1896
-
1897
- Buffer$1.prototype.toString = function toString () {
1898
- var length = this.length | 0;
1899
- if (length === 0) return ''
1900
- if (arguments.length === 0) return utf8Slice(this, 0, length)
1901
- return slowToString.apply(this, arguments)
1902
- };
1903
-
1904
- Buffer$1.prototype.equals = function equals (b) {
1905
- if (!internalIsBuffer(b)) throw new TypeError('Argument must be a Buffer')
1906
- if (this === b) return true
1907
- return Buffer$1.compare(this, b) === 0
1908
- };
1909
-
1910
- Buffer$1.prototype.inspect = function inspect () {
1911
- var str = '';
1912
- var max = INSPECT_MAX_BYTES;
1913
- if (this.length > 0) {
1914
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ');
1915
- if (this.length > max) str += ' ... ';
1916
- }
1917
- return '<Buffer ' + str + '>'
1918
- };
1919
-
1920
- Buffer$1.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1921
- if (!internalIsBuffer(target)) {
1922
- throw new TypeError('Argument must be a Buffer')
1923
- }
1924
-
1925
- if (start === undefined) {
1926
- start = 0;
1927
- }
1928
- if (end === undefined) {
1929
- end = target ? target.length : 0;
1930
- }
1931
- if (thisStart === undefined) {
1932
- thisStart = 0;
1933
- }
1934
- if (thisEnd === undefined) {
1935
- thisEnd = this.length;
1936
- }
1937
-
1938
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1939
- throw new RangeError('out of range index')
1940
- }
1941
-
1942
- if (thisStart >= thisEnd && start >= end) {
1943
- return 0
1944
- }
1945
- if (thisStart >= thisEnd) {
1946
- return -1
1947
- }
1948
- if (start >= end) {
1949
- return 1
1950
- }
1951
-
1952
- start >>>= 0;
1953
- end >>>= 0;
1954
- thisStart >>>= 0;
1955
- thisEnd >>>= 0;
1956
-
1957
- if (this === target) return 0
1958
-
1959
- var x = thisEnd - thisStart;
1960
- var y = end - start;
1961
- var len = Math.min(x, y);
1962
-
1963
- var thisCopy = this.slice(thisStart, thisEnd);
1964
- var targetCopy = target.slice(start, end);
1965
-
1966
- for (var i = 0; i < len; ++i) {
1967
- if (thisCopy[i] !== targetCopy[i]) {
1968
- x = thisCopy[i];
1969
- y = targetCopy[i];
1970
- break
1971
- }
1972
- }
1973
-
1974
- if (x < y) return -1
1975
- if (y < x) return 1
1976
- return 0
1977
- };
1978
-
1979
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1980
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1981
- //
1982
- // Arguments:
1983
- // - buffer - a Buffer to search
1984
- // - val - a string, Buffer, or number
1985
- // - byteOffset - an index into `buffer`; will be clamped to an int32
1986
- // - encoding - an optional encoding, relevant is val is a string
1987
- // - dir - true for indexOf, false for lastIndexOf
1988
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1989
- // Empty buffer means no match
1990
- if (buffer.length === 0) return -1
1991
-
1992
- // Normalize byteOffset
1993
- if (typeof byteOffset === 'string') {
1994
- encoding = byteOffset;
1995
- byteOffset = 0;
1996
- } else if (byteOffset > 0x7fffffff) {
1997
- byteOffset = 0x7fffffff;
1998
- } else if (byteOffset < -2147483648) {
1999
- byteOffset = -2147483648;
2000
- }
2001
- byteOffset = +byteOffset; // Coerce to Number.
2002
- if (isNaN(byteOffset)) {
2003
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
2004
- byteOffset = dir ? 0 : (buffer.length - 1);
2005
- }
2006
-
2007
- // Normalize byteOffset: negative offsets start from the end of the buffer
2008
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
2009
- if (byteOffset >= buffer.length) {
2010
- if (dir) return -1
2011
- else byteOffset = buffer.length - 1;
2012
- } else if (byteOffset < 0) {
2013
- if (dir) byteOffset = 0;
2014
- else return -1
2015
- }
2016
-
2017
- // Normalize val
2018
- if (typeof val === 'string') {
2019
- val = Buffer$1.from(val, encoding);
2020
- }
2021
-
2022
- // Finally, search either indexOf (if dir is true) or lastIndexOf
2023
- if (internalIsBuffer(val)) {
2024
- // Special case: looking for empty string/buffer always fails
2025
- if (val.length === 0) {
2026
- return -1
2027
- }
2028
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
2029
- } else if (typeof val === 'number') {
2030
- val = val & 0xFF; // Search for a byte value [0-255]
2031
- if (Buffer$1.TYPED_ARRAY_SUPPORT &&
2032
- typeof Uint8Array.prototype.indexOf === 'function') {
2033
- if (dir) {
2034
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
2035
- } else {
2036
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
2037
- }
2038
- }
2039
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
2040
- }
2041
-
2042
- throw new TypeError('val must be string, number or Buffer')
2043
- }
2044
-
2045
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
2046
- var indexSize = 1;
2047
- var arrLength = arr.length;
2048
- var valLength = val.length;
2049
-
2050
- if (encoding !== undefined) {
2051
- encoding = String(encoding).toLowerCase();
2052
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
2053
- encoding === 'utf16le' || encoding === 'utf-16le') {
2054
- if (arr.length < 2 || val.length < 2) {
2055
- return -1
2056
- }
2057
- indexSize = 2;
2058
- arrLength /= 2;
2059
- valLength /= 2;
2060
- byteOffset /= 2;
2061
- }
2062
- }
2063
-
2064
- function read (buf, i) {
2065
- if (indexSize === 1) {
2066
- return buf[i]
2067
- } else {
2068
- return buf.readUInt16BE(i * indexSize)
2069
- }
2070
- }
2071
-
2072
- var i;
2073
- if (dir) {
2074
- var foundIndex = -1;
2075
- for (i = byteOffset; i < arrLength; i++) {
2076
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
2077
- if (foundIndex === -1) foundIndex = i;
2078
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
2079
- } else {
2080
- if (foundIndex !== -1) i -= i - foundIndex;
2081
- foundIndex = -1;
2082
- }
2083
- }
2084
- } else {
2085
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
2086
- for (i = byteOffset; i >= 0; i--) {
2087
- var found = true;
2088
- for (var j = 0; j < valLength; j++) {
2089
- if (read(arr, i + j) !== read(val, j)) {
2090
- found = false;
2091
- break
2092
- }
2093
- }
2094
- if (found) return i
2095
- }
2096
- }
2097
-
2098
- return -1
2099
- }
2100
-
2101
- Buffer$1.prototype.includes = function includes (val, byteOffset, encoding) {
2102
- return this.indexOf(val, byteOffset, encoding) !== -1
2103
- };
2104
-
2105
- Buffer$1.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
2106
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
2107
- };
2108
-
2109
- Buffer$1.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
2110
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
2111
- };
2112
-
2113
- function hexWrite (buf, string, offset, length) {
2114
- offset = Number(offset) || 0;
2115
- var remaining = buf.length - offset;
2116
- if (!length) {
2117
- length = remaining;
2118
- } else {
2119
- length = Number(length);
2120
- if (length > remaining) {
2121
- length = remaining;
2122
- }
2123
- }
2124
-
2125
- // must be an even number of digits
2126
- var strLen = string.length;
2127
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
2128
-
2129
- if (length > strLen / 2) {
2130
- length = strLen / 2;
2131
- }
2132
- for (var i = 0; i < length; ++i) {
2133
- var parsed = parseInt(string.substr(i * 2, 2), 16);
2134
- if (isNaN(parsed)) return i
2135
- buf[offset + i] = parsed;
2136
- }
2137
- return i
2138
- }
2139
-
2140
- function utf8Write (buf, string, offset, length) {
2141
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
2142
- }
2143
-
2144
- function asciiWrite (buf, string, offset, length) {
2145
- return blitBuffer(asciiToBytes(string), buf, offset, length)
2146
- }
2147
-
2148
- function latin1Write (buf, string, offset, length) {
2149
- return asciiWrite(buf, string, offset, length)
2150
- }
2151
-
2152
- function base64Write (buf, string, offset, length) {
2153
- return blitBuffer(base64ToBytes(string), buf, offset, length)
2154
- }
2155
-
2156
- function ucs2Write (buf, string, offset, length) {
2157
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
2158
- }
2159
-
2160
- Buffer$1.prototype.write = function write (string, offset, length, encoding) {
2161
- // Buffer#write(string)
2162
- if (offset === undefined) {
2163
- encoding = 'utf8';
2164
- length = this.length;
2165
- offset = 0;
2166
- // Buffer#write(string, encoding)
2167
- } else if (length === undefined && typeof offset === 'string') {
2168
- encoding = offset;
2169
- length = this.length;
2170
- offset = 0;
2171
- // Buffer#write(string, offset[, length][, encoding])
2172
- } else if (isFinite(offset)) {
2173
- offset = offset | 0;
2174
- if (isFinite(length)) {
2175
- length = length | 0;
2176
- if (encoding === undefined) encoding = 'utf8';
2177
- } else {
2178
- encoding = length;
2179
- length = undefined;
2180
- }
2181
- // legacy write(string, encoding, offset, length) - remove in v0.13
2182
- } else {
2183
- throw new Error(
2184
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
2185
- )
2186
- }
2187
-
2188
- var remaining = this.length - offset;
2189
- if (length === undefined || length > remaining) length = remaining;
2190
-
2191
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
2192
- throw new RangeError('Attempt to write outside buffer bounds')
2193
- }
2194
-
2195
- if (!encoding) encoding = 'utf8';
2196
-
2197
- var loweredCase = false;
2198
- for (;;) {
2199
- switch (encoding) {
2200
- case 'hex':
2201
- return hexWrite(this, string, offset, length)
2202
-
2203
- case 'utf8':
2204
- case 'utf-8':
2205
- return utf8Write(this, string, offset, length)
2206
-
2207
- case 'ascii':
2208
- return asciiWrite(this, string, offset, length)
2209
-
2210
- case 'latin1':
2211
- case 'binary':
2212
- return latin1Write(this, string, offset, length)
2213
-
2214
- case 'base64':
2215
- // Warning: maxLength not taken into account in base64Write
2216
- return base64Write(this, string, offset, length)
2217
-
2218
- case 'ucs2':
2219
- case 'ucs-2':
2220
- case 'utf16le':
2221
- case 'utf-16le':
2222
- return ucs2Write(this, string, offset, length)
2223
-
2224
- default:
2225
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
2226
- encoding = ('' + encoding).toLowerCase();
2227
- loweredCase = true;
2228
- }
2229
- }
2230
- };
2231
-
2232
- Buffer$1.prototype.toJSON = function toJSON () {
2233
- return {
2234
- type: 'Buffer',
2235
- data: Array.prototype.slice.call(this._arr || this, 0)
2236
- }
2237
- };
2238
-
2239
- function base64Slice (buf, start, end) {
2240
- if (start === 0 && end === buf.length) {
2241
- return fromByteArray(buf)
2242
- } else {
2243
- return fromByteArray(buf.slice(start, end))
2244
- }
2245
- }
2246
-
2247
- function utf8Slice (buf, start, end) {
2248
- end = Math.min(buf.length, end);
2249
- var res = [];
2250
-
2251
- var i = start;
2252
- while (i < end) {
2253
- var firstByte = buf[i];
2254
- var codePoint = null;
2255
- var bytesPerSequence = (firstByte > 0xEF) ? 4
2256
- : (firstByte > 0xDF) ? 3
2257
- : (firstByte > 0xBF) ? 2
2258
- : 1;
2259
-
2260
- if (i + bytesPerSequence <= end) {
2261
- var secondByte, thirdByte, fourthByte, tempCodePoint;
2262
-
2263
- switch (bytesPerSequence) {
2264
- case 1:
2265
- if (firstByte < 0x80) {
2266
- codePoint = firstByte;
2267
- }
2268
- break
2269
- case 2:
2270
- secondByte = buf[i + 1];
2271
- if ((secondByte & 0xC0) === 0x80) {
2272
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
2273
- if (tempCodePoint > 0x7F) {
2274
- codePoint = tempCodePoint;
2275
- }
2276
- }
2277
- break
2278
- case 3:
2279
- secondByte = buf[i + 1];
2280
- thirdByte = buf[i + 2];
2281
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
2282
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
2283
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
2284
- codePoint = tempCodePoint;
2285
- }
2286
- }
2287
- break
2288
- case 4:
2289
- secondByte = buf[i + 1];
2290
- thirdByte = buf[i + 2];
2291
- fourthByte = buf[i + 3];
2292
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
2293
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
2294
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
2295
- codePoint = tempCodePoint;
2296
- }
2297
- }
2298
- }
2299
- }
2300
-
2301
- if (codePoint === null) {
2302
- // we did not generate a valid codePoint so insert a
2303
- // replacement char (U+FFFD) and advance only 1 byte
2304
- codePoint = 0xFFFD;
2305
- bytesPerSequence = 1;
2306
- } else if (codePoint > 0xFFFF) {
2307
- // encode to utf16 (surrogate pair dance)
2308
- codePoint -= 0x10000;
2309
- res.push(codePoint >>> 10 & 0x3FF | 0xD800);
2310
- codePoint = 0xDC00 | codePoint & 0x3FF;
2311
- }
2312
-
2313
- res.push(codePoint);
2314
- i += bytesPerSequence;
2315
- }
2316
-
2317
- return decodeCodePointsArray(res)
2318
- }
2319
-
2320
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
2321
- // the lowest limit is Chrome, with 0x10000 args.
2322
- // We go 1 magnitude less, for safety
2323
- var MAX_ARGUMENTS_LENGTH = 0x1000;
2324
-
2325
- function decodeCodePointsArray (codePoints) {
2326
- var len = codePoints.length;
2327
- if (len <= MAX_ARGUMENTS_LENGTH) {
2328
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
2329
- }
2330
-
2331
- // Decode in chunks to avoid "call stack size exceeded".
2332
- var res = '';
2333
- var i = 0;
2334
- while (i < len) {
2335
- res += String.fromCharCode.apply(
2336
- String,
2337
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
2338
- );
2339
- }
2340
- return res
2341
- }
2342
-
2343
- function asciiSlice (buf, start, end) {
2344
- var ret = '';
2345
- end = Math.min(buf.length, end);
2346
-
2347
- for (var i = start; i < end; ++i) {
2348
- ret += String.fromCharCode(buf[i] & 0x7F);
2349
- }
2350
- return ret
2351
- }
2352
-
2353
- function latin1Slice (buf, start, end) {
2354
- var ret = '';
2355
- end = Math.min(buf.length, end);
2356
-
2357
- for (var i = start; i < end; ++i) {
2358
- ret += String.fromCharCode(buf[i]);
2359
- }
2360
- return ret
2361
- }
2362
-
2363
- function hexSlice (buf, start, end) {
2364
- var len = buf.length;
2365
-
2366
- if (!start || start < 0) start = 0;
2367
- if (!end || end < 0 || end > len) end = len;
2368
-
2369
- var out = '';
2370
- for (var i = start; i < end; ++i) {
2371
- out += toHex(buf[i]);
2372
- }
2373
- return out
2374
- }
2375
-
2376
- function utf16leSlice (buf, start, end) {
2377
- var bytes = buf.slice(start, end);
2378
- var res = '';
2379
- for (var i = 0; i < bytes.length; i += 2) {
2380
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
2381
- }
2382
- return res
2383
- }
2384
-
2385
- Buffer$1.prototype.slice = function slice (start, end) {
2386
- var len = this.length;
2387
- start = ~~start;
2388
- end = end === undefined ? len : ~~end;
2389
-
2390
- if (start < 0) {
2391
- start += len;
2392
- if (start < 0) start = 0;
2393
- } else if (start > len) {
2394
- start = len;
2395
- }
2396
-
2397
- if (end < 0) {
2398
- end += len;
2399
- if (end < 0) end = 0;
2400
- } else if (end > len) {
2401
- end = len;
2402
- }
2403
-
2404
- if (end < start) end = start;
2405
-
2406
- var newBuf;
2407
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2408
- newBuf = this.subarray(start, end);
2409
- newBuf.__proto__ = Buffer$1.prototype;
2410
- } else {
2411
- var sliceLen = end - start;
2412
- newBuf = new Buffer$1(sliceLen, undefined);
2413
- for (var i = 0; i < sliceLen; ++i) {
2414
- newBuf[i] = this[i + start];
2415
- }
2416
- }
2417
-
2418
- return newBuf
2419
- };
2420
-
2421
- /*
2422
- * Need to make sure that buffer isn't trying to write out of bounds.
2423
- */
2424
- function checkOffset (offset, ext, length) {
2425
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
2426
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
2427
- }
2428
-
2429
- Buffer$1.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
2430
- offset = offset | 0;
2431
- byteLength = byteLength | 0;
2432
- if (!noAssert) checkOffset(offset, byteLength, this.length);
2433
-
2434
- var val = this[offset];
2435
- var mul = 1;
2436
- var i = 0;
2437
- while (++i < byteLength && (mul *= 0x100)) {
2438
- val += this[offset + i] * mul;
2439
- }
2440
-
2441
- return val
2442
- };
2443
-
2444
- Buffer$1.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
2445
- offset = offset | 0;
2446
- byteLength = byteLength | 0;
2447
- if (!noAssert) {
2448
- checkOffset(offset, byteLength, this.length);
2449
- }
2450
-
2451
- var val = this[offset + --byteLength];
2452
- var mul = 1;
2453
- while (byteLength > 0 && (mul *= 0x100)) {
2454
- val += this[offset + --byteLength] * mul;
2455
- }
2456
-
2457
- return val
2458
- };
2459
-
2460
- Buffer$1.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
2461
- if (!noAssert) checkOffset(offset, 1, this.length);
2462
- return this[offset]
2463
- };
2464
-
2465
- Buffer$1.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
2466
- if (!noAssert) checkOffset(offset, 2, this.length);
2467
- return this[offset] | (this[offset + 1] << 8)
2468
- };
2469
-
2470
- Buffer$1.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
2471
- if (!noAssert) checkOffset(offset, 2, this.length);
2472
- return (this[offset] << 8) | this[offset + 1]
2473
- };
2474
-
2475
- Buffer$1.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
2476
- if (!noAssert) checkOffset(offset, 4, this.length);
2477
-
2478
- return ((this[offset]) |
2479
- (this[offset + 1] << 8) |
2480
- (this[offset + 2] << 16)) +
2481
- (this[offset + 3] * 0x1000000)
2482
- };
2483
-
2484
- Buffer$1.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
2485
- if (!noAssert) checkOffset(offset, 4, this.length);
2486
-
2487
- return (this[offset] * 0x1000000) +
2488
- ((this[offset + 1] << 16) |
2489
- (this[offset + 2] << 8) |
2490
- this[offset + 3])
2491
- };
2492
-
2493
- Buffer$1.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
2494
- offset = offset | 0;
2495
- byteLength = byteLength | 0;
2496
- if (!noAssert) checkOffset(offset, byteLength, this.length);
2497
-
2498
- var val = this[offset];
2499
- var mul = 1;
2500
- var i = 0;
2501
- while (++i < byteLength && (mul *= 0x100)) {
2502
- val += this[offset + i] * mul;
2503
- }
2504
- mul *= 0x80;
2505
-
2506
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
2507
-
2508
- return val
2509
- };
2510
-
2511
- Buffer$1.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
2512
- offset = offset | 0;
2513
- byteLength = byteLength | 0;
2514
- if (!noAssert) checkOffset(offset, byteLength, this.length);
2515
-
2516
- var i = byteLength;
2517
- var mul = 1;
2518
- var val = this[offset + --i];
2519
- while (i > 0 && (mul *= 0x100)) {
2520
- val += this[offset + --i] * mul;
2521
- }
2522
- mul *= 0x80;
2523
-
2524
- if (val >= mul) val -= Math.pow(2, 8 * byteLength);
2525
-
2526
- return val
2527
- };
2528
-
2529
- Buffer$1.prototype.readInt8 = function readInt8 (offset, noAssert) {
2530
- if (!noAssert) checkOffset(offset, 1, this.length);
2531
- if (!(this[offset] & 0x80)) return (this[offset])
2532
- return ((0xff - this[offset] + 1) * -1)
2533
- };
2534
-
2535
- Buffer$1.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
2536
- if (!noAssert) checkOffset(offset, 2, this.length);
2537
- var val = this[offset] | (this[offset + 1] << 8);
2538
- return (val & 0x8000) ? val | 0xFFFF0000 : val
2539
- };
2540
-
2541
- Buffer$1.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
2542
- if (!noAssert) checkOffset(offset, 2, this.length);
2543
- var val = this[offset + 1] | (this[offset] << 8);
2544
- return (val & 0x8000) ? val | 0xFFFF0000 : val
2545
- };
2546
-
2547
- Buffer$1.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
2548
- if (!noAssert) checkOffset(offset, 4, this.length);
2549
-
2550
- return (this[offset]) |
2551
- (this[offset + 1] << 8) |
2552
- (this[offset + 2] << 16) |
2553
- (this[offset + 3] << 24)
2554
- };
2555
-
2556
- Buffer$1.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
2557
- if (!noAssert) checkOffset(offset, 4, this.length);
2558
-
2559
- return (this[offset] << 24) |
2560
- (this[offset + 1] << 16) |
2561
- (this[offset + 2] << 8) |
2562
- (this[offset + 3])
2563
- };
2564
-
2565
- Buffer$1.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
2566
- if (!noAssert) checkOffset(offset, 4, this.length);
2567
- return read(this, offset, true, 23, 4)
2568
- };
2569
-
2570
- Buffer$1.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
2571
- if (!noAssert) checkOffset(offset, 4, this.length);
2572
- return read(this, offset, false, 23, 4)
2573
- };
2574
-
2575
- Buffer$1.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
2576
- if (!noAssert) checkOffset(offset, 8, this.length);
2577
- return read(this, offset, true, 52, 8)
2578
- };
2579
-
2580
- Buffer$1.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
2581
- if (!noAssert) checkOffset(offset, 8, this.length);
2582
- return read(this, offset, false, 52, 8)
2583
- };
2584
-
2585
- function checkInt (buf, value, offset, ext, max, min) {
2586
- if (!internalIsBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
2587
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
2588
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
2589
- }
2590
-
2591
- Buffer$1.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
2592
- value = +value;
2593
- offset = offset | 0;
2594
- byteLength = byteLength | 0;
2595
- if (!noAssert) {
2596
- var maxBytes = Math.pow(2, 8 * byteLength) - 1;
2597
- checkInt(this, value, offset, byteLength, maxBytes, 0);
2598
- }
2599
-
2600
- var mul = 1;
2601
- var i = 0;
2602
- this[offset] = value & 0xFF;
2603
- while (++i < byteLength && (mul *= 0x100)) {
2604
- this[offset + i] = (value / mul) & 0xFF;
2605
- }
2606
-
2607
- return offset + byteLength
2608
- };
2609
-
2610
- Buffer$1.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
2611
- value = +value;
2612
- offset = offset | 0;
2613
- byteLength = byteLength | 0;
2614
- if (!noAssert) {
2615
- var maxBytes = Math.pow(2, 8 * byteLength) - 1;
2616
- checkInt(this, value, offset, byteLength, maxBytes, 0);
2617
- }
2618
-
2619
- var i = byteLength - 1;
2620
- var mul = 1;
2621
- this[offset + i] = value & 0xFF;
2622
- while (--i >= 0 && (mul *= 0x100)) {
2623
- this[offset + i] = (value / mul) & 0xFF;
2624
- }
2625
-
2626
- return offset + byteLength
2627
- };
2628
-
2629
- Buffer$1.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
2630
- value = +value;
2631
- offset = offset | 0;
2632
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
2633
- if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
2634
- this[offset] = (value & 0xff);
2635
- return offset + 1
2636
- };
2637
-
2638
- function objectWriteUInt16 (buf, value, offset, littleEndian) {
2639
- if (value < 0) value = 0xffff + value + 1;
2640
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
2641
- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
2642
- (littleEndian ? i : 1 - i) * 8;
2643
- }
2644
- }
2645
-
2646
- Buffer$1.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
2647
- value = +value;
2648
- offset = offset | 0;
2649
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
2650
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2651
- this[offset] = (value & 0xff);
2652
- this[offset + 1] = (value >>> 8);
2653
- } else {
2654
- objectWriteUInt16(this, value, offset, true);
2655
- }
2656
- return offset + 2
2657
- };
2658
-
2659
- Buffer$1.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
2660
- value = +value;
2661
- offset = offset | 0;
2662
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
2663
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2664
- this[offset] = (value >>> 8);
2665
- this[offset + 1] = (value & 0xff);
2666
- } else {
2667
- objectWriteUInt16(this, value, offset, false);
2668
- }
2669
- return offset + 2
2670
- };
2671
-
2672
- function objectWriteUInt32 (buf, value, offset, littleEndian) {
2673
- if (value < 0) value = 0xffffffff + value + 1;
2674
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
2675
- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff;
2676
- }
2677
- }
2678
-
2679
- Buffer$1.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
2680
- value = +value;
2681
- offset = offset | 0;
2682
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
2683
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2684
- this[offset + 3] = (value >>> 24);
2685
- this[offset + 2] = (value >>> 16);
2686
- this[offset + 1] = (value >>> 8);
2687
- this[offset] = (value & 0xff);
2688
- } else {
2689
- objectWriteUInt32(this, value, offset, true);
2690
- }
2691
- return offset + 4
2692
- };
2693
-
2694
- Buffer$1.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
2695
- value = +value;
2696
- offset = offset | 0;
2697
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
2698
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2699
- this[offset] = (value >>> 24);
2700
- this[offset + 1] = (value >>> 16);
2701
- this[offset + 2] = (value >>> 8);
2702
- this[offset + 3] = (value & 0xff);
2703
- } else {
2704
- objectWriteUInt32(this, value, offset, false);
2705
- }
2706
- return offset + 4
2707
- };
2708
-
2709
- Buffer$1.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
2710
- value = +value;
2711
- offset = offset | 0;
2712
- if (!noAssert) {
2713
- var limit = Math.pow(2, 8 * byteLength - 1);
2714
-
2715
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
2716
- }
2717
-
2718
- var i = 0;
2719
- var mul = 1;
2720
- var sub = 0;
2721
- this[offset] = value & 0xFF;
2722
- while (++i < byteLength && (mul *= 0x100)) {
2723
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2724
- sub = 1;
2725
- }
2726
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
2727
- }
2728
-
2729
- return offset + byteLength
2730
- };
2731
-
2732
- Buffer$1.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
2733
- value = +value;
2734
- offset = offset | 0;
2735
- if (!noAssert) {
2736
- var limit = Math.pow(2, 8 * byteLength - 1);
2737
-
2738
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
2739
- }
2740
-
2741
- var i = byteLength - 1;
2742
- var mul = 1;
2743
- var sub = 0;
2744
- this[offset + i] = value & 0xFF;
2745
- while (--i >= 0 && (mul *= 0x100)) {
2746
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2747
- sub = 1;
2748
- }
2749
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
2750
- }
2751
-
2752
- return offset + byteLength
2753
- };
2754
-
2755
- Buffer$1.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2756
- value = +value;
2757
- offset = offset | 0;
2758
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
2759
- if (!Buffer$1.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
2760
- if (value < 0) value = 0xff + value + 1;
2761
- this[offset] = (value & 0xff);
2762
- return offset + 1
2763
- };
2764
-
2765
- Buffer$1.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2766
- value = +value;
2767
- offset = offset | 0;
2768
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
2769
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2770
- this[offset] = (value & 0xff);
2771
- this[offset + 1] = (value >>> 8);
2772
- } else {
2773
- objectWriteUInt16(this, value, offset, true);
2774
- }
2775
- return offset + 2
2776
- };
2777
-
2778
- Buffer$1.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2779
- value = +value;
2780
- offset = offset | 0;
2781
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
2782
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2783
- this[offset] = (value >>> 8);
2784
- this[offset + 1] = (value & 0xff);
2785
- } else {
2786
- objectWriteUInt16(this, value, offset, false);
2787
- }
2788
- return offset + 2
2789
- };
2790
-
2791
- Buffer$1.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2792
- value = +value;
2793
- offset = offset | 0;
2794
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
2795
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2796
- this[offset] = (value & 0xff);
2797
- this[offset + 1] = (value >>> 8);
2798
- this[offset + 2] = (value >>> 16);
2799
- this[offset + 3] = (value >>> 24);
2800
- } else {
2801
- objectWriteUInt32(this, value, offset, true);
2802
- }
2803
- return offset + 4
2804
- };
2805
-
2806
- Buffer$1.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2807
- value = +value;
2808
- offset = offset | 0;
2809
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
2810
- if (value < 0) value = 0xffffffff + value + 1;
2811
- if (Buffer$1.TYPED_ARRAY_SUPPORT) {
2812
- this[offset] = (value >>> 24);
2813
- this[offset + 1] = (value >>> 16);
2814
- this[offset + 2] = (value >>> 8);
2815
- this[offset + 3] = (value & 0xff);
2816
- } else {
2817
- objectWriteUInt32(this, value, offset, false);
2818
- }
2819
- return offset + 4
2820
- };
2821
-
2822
- function checkIEEE754 (buf, value, offset, ext, max, min) {
2823
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
2824
- if (offset < 0) throw new RangeError('Index out of range')
2825
- }
2826
-
2827
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
2828
- if (!noAssert) {
2829
- checkIEEE754(buf, value, offset, 4);
2830
- }
2831
- write(buf, value, offset, littleEndian, 23, 4);
2832
- return offset + 4
2833
- }
2834
-
2835
- Buffer$1.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2836
- return writeFloat(this, value, offset, true, noAssert)
2837
- };
2838
-
2839
- Buffer$1.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2840
- return writeFloat(this, value, offset, false, noAssert)
2841
- };
2842
-
2843
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
2844
- if (!noAssert) {
2845
- checkIEEE754(buf, value, offset, 8);
2846
- }
2847
- write(buf, value, offset, littleEndian, 52, 8);
2848
- return offset + 8
2849
- }
2850
-
2851
- Buffer$1.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2852
- return writeDouble(this, value, offset, true, noAssert)
2853
- };
2854
-
2855
- Buffer$1.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2856
- return writeDouble(this, value, offset, false, noAssert)
2857
- };
2858
-
2859
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2860
- Buffer$1.prototype.copy = function copy (target, targetStart, start, end) {
2861
- if (!start) start = 0;
2862
- if (!end && end !== 0) end = this.length;
2863
- if (targetStart >= target.length) targetStart = target.length;
2864
- if (!targetStart) targetStart = 0;
2865
- if (end > 0 && end < start) end = start;
2866
-
2867
- // Copy 0 bytes; we're done
2868
- if (end === start) return 0
2869
- if (target.length === 0 || this.length === 0) return 0
2870
-
2871
- // Fatal error conditions
2872
- if (targetStart < 0) {
2873
- throw new RangeError('targetStart out of bounds')
2874
- }
2875
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
2876
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
2877
-
2878
- // Are we oob?
2879
- if (end > this.length) end = this.length;
2880
- if (target.length - targetStart < end - start) {
2881
- end = target.length - targetStart + start;
2882
- }
2883
-
2884
- var len = end - start;
2885
- var i;
2886
-
2887
- if (this === target && start < targetStart && targetStart < end) {
2888
- // descending copy from end
2889
- for (i = len - 1; i >= 0; --i) {
2890
- target[i + targetStart] = this[i + start];
2891
- }
2892
- } else if (len < 1000 || !Buffer$1.TYPED_ARRAY_SUPPORT) {
2893
- // ascending copy from start
2894
- for (i = 0; i < len; ++i) {
2895
- target[i + targetStart] = this[i + start];
2896
- }
2897
- } else {
2898
- Uint8Array.prototype.set.call(
2899
- target,
2900
- this.subarray(start, start + len),
2901
- targetStart
2902
- );
2903
- }
2904
-
2905
- return len
2906
- };
2907
-
2908
- // Usage:
2909
- // buffer.fill(number[, offset[, end]])
2910
- // buffer.fill(buffer[, offset[, end]])
2911
- // buffer.fill(string[, offset[, end]][, encoding])
2912
- Buffer$1.prototype.fill = function fill (val, start, end, encoding) {
2913
- // Handle string cases:
2914
- if (typeof val === 'string') {
2915
- if (typeof start === 'string') {
2916
- encoding = start;
2917
- start = 0;
2918
- end = this.length;
2919
- } else if (typeof end === 'string') {
2920
- encoding = end;
2921
- end = this.length;
2922
- }
2923
- if (val.length === 1) {
2924
- var code = val.charCodeAt(0);
2925
- if (code < 256) {
2926
- val = code;
2927
- }
2928
- }
2929
- if (encoding !== undefined && typeof encoding !== 'string') {
2930
- throw new TypeError('encoding must be a string')
2931
- }
2932
- if (typeof encoding === 'string' && !Buffer$1.isEncoding(encoding)) {
2933
- throw new TypeError('Unknown encoding: ' + encoding)
2934
- }
2935
- } else if (typeof val === 'number') {
2936
- val = val & 255;
2937
- }
2938
-
2939
- // Invalid ranges are not set to a default, so can range check early.
2940
- if (start < 0 || this.length < start || this.length < end) {
2941
- throw new RangeError('Out of range index')
2942
- }
2943
-
2944
- if (end <= start) {
2945
- return this
2946
- }
2947
-
2948
- start = start >>> 0;
2949
- end = end === undefined ? this.length : end >>> 0;
2950
-
2951
- if (!val) val = 0;
2952
-
2953
- var i;
2954
- if (typeof val === 'number') {
2955
- for (i = start; i < end; ++i) {
2956
- this[i] = val;
2957
- }
2958
- } else {
2959
- var bytes = internalIsBuffer(val)
2960
- ? val
2961
- : utf8ToBytes(new Buffer$1(val, encoding).toString());
2962
- var len = bytes.length;
2963
- for (i = 0; i < end - start; ++i) {
2964
- this[i + start] = bytes[i % len];
2965
- }
2966
- }
2967
-
2968
- return this
2969
- };
2970
-
2971
- // HELPER FUNCTIONS
2972
- // ================
2973
-
2974
- var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
2975
-
2976
- function base64clean (str) {
2977
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
2978
- str = stringtrim(str).replace(INVALID_BASE64_RE, '');
2979
- // Node converts strings with length < 2 to ''
2980
- if (str.length < 2) return ''
2981
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2982
- while (str.length % 4 !== 0) {
2983
- str = str + '=';
2984
- }
2985
- return str
2986
- }
2987
-
2988
- function stringtrim (str) {
2989
- if (str.trim) return str.trim()
2990
- return str.replace(/^\s+|\s+$/g, '')
2991
- }
2992
-
2993
- function toHex (n) {
2994
- if (n < 16) return '0' + n.toString(16)
2995
- return n.toString(16)
2996
- }
2997
-
2998
- function utf8ToBytes (string, units) {
2999
- units = units || Infinity;
3000
- var codePoint;
3001
- var length = string.length;
3002
- var leadSurrogate = null;
3003
- var bytes = [];
3004
-
3005
- for (var i = 0; i < length; ++i) {
3006
- codePoint = string.charCodeAt(i);
3007
-
3008
- // is surrogate component
3009
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
3010
- // last char was a lead
3011
- if (!leadSurrogate) {
3012
- // no lead yet
3013
- if (codePoint > 0xDBFF) {
3014
- // unexpected trail
3015
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3016
- continue
3017
- } else if (i + 1 === length) {
3018
- // unpaired lead
3019
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3020
- continue
3021
- }
3022
-
3023
- // valid lead
3024
- leadSurrogate = codePoint;
3025
-
3026
- continue
3027
- }
3028
-
3029
- // 2 leads in a row
3030
- if (codePoint < 0xDC00) {
3031
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3032
- leadSurrogate = codePoint;
3033
- continue
3034
- }
3035
-
3036
- // valid surrogate pair
3037
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
3038
- } else if (leadSurrogate) {
3039
- // valid bmp char, but last char was a lead
3040
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
3041
- }
3042
-
3043
- leadSurrogate = null;
3044
-
3045
- // encode utf8
3046
- if (codePoint < 0x80) {
3047
- if ((units -= 1) < 0) break
3048
- bytes.push(codePoint);
3049
- } else if (codePoint < 0x800) {
3050
- if ((units -= 2) < 0) break
3051
- bytes.push(
3052
- codePoint >> 0x6 | 0xC0,
3053
- codePoint & 0x3F | 0x80
3054
- );
3055
- } else if (codePoint < 0x10000) {
3056
- if ((units -= 3) < 0) break
3057
- bytes.push(
3058
- codePoint >> 0xC | 0xE0,
3059
- codePoint >> 0x6 & 0x3F | 0x80,
3060
- codePoint & 0x3F | 0x80
3061
- );
3062
- } else if (codePoint < 0x110000) {
3063
- if ((units -= 4) < 0) break
3064
- bytes.push(
3065
- codePoint >> 0x12 | 0xF0,
3066
- codePoint >> 0xC & 0x3F | 0x80,
3067
- codePoint >> 0x6 & 0x3F | 0x80,
3068
- codePoint & 0x3F | 0x80
3069
- );
3070
- } else {
3071
- throw new Error('Invalid code point')
3072
- }
3073
- }
3074
-
3075
- return bytes
3076
- }
3077
-
3078
- function asciiToBytes (str) {
3079
- var byteArray = [];
3080
- for (var i = 0; i < str.length; ++i) {
3081
- // Node's code seems to be doing this and not & 0x7F..
3082
- byteArray.push(str.charCodeAt(i) & 0xFF);
3083
- }
3084
- return byteArray
3085
- }
3086
-
3087
- function utf16leToBytes (str, units) {
3088
- var c, hi, lo;
3089
- var byteArray = [];
3090
- for (var i = 0; i < str.length; ++i) {
3091
- if ((units -= 2) < 0) break
3092
-
3093
- c = str.charCodeAt(i);
3094
- hi = c >> 8;
3095
- lo = c % 256;
3096
- byteArray.push(lo);
3097
- byteArray.push(hi);
3098
- }
3099
-
3100
- return byteArray
3101
- }
3102
-
3103
-
3104
- function base64ToBytes (str) {
3105
- return toByteArray(base64clean(str))
3106
- }
3107
-
3108
- function blitBuffer (src, dst, offset, length) {
3109
- for (var i = 0; i < length; ++i) {
3110
- if ((i + offset >= dst.length) || (i >= src.length)) break
3111
- dst[i + offset] = src[i];
3112
- }
3113
- return i
3114
- }
3115
-
3116
- function isnan (val) {
3117
- return val !== val // eslint-disable-line no-self-compare
3118
- }
3119
-
3120
-
3121
- // the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
3122
- // The _isBuffer check is for Safari 5-7 support, because it's missing
3123
- // Object.prototype.constructor. Remove this eventually
3124
- function isBuffer$1(obj) {
3125
- return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj))
3126
- }
3127
-
3128
- function isFastBuffer (obj) {
3129
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
3130
- }
3131
-
3132
- // For Node v0.10 support. Remove this eventually.
3133
- function isSlowBuffer (obj) {
3134
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
3135
- }
3136
-
3137
1158
  var inherits;
3138
1159
  if (typeof Object.create === 'function'){
3139
1160
  inherits = function inherits(ctor, superCtor) {
@@ -3158,6 +1179,27 @@ var contentfulManagement = (function (exports) {
3158
1179
  };
3159
1180
  }
3160
1181
 
1182
+ // Copyright Joyent, Inc. and other Node contributors.
1183
+ //
1184
+ // Permission is hereby granted, free of charge, to any person obtaining a
1185
+ // copy of this software and associated documentation files (the
1186
+ // "Software"), to deal in the Software without restriction, including
1187
+ // without limitation the rights to use, copy, modify, merge, publish,
1188
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
1189
+ // persons to whom the Software is furnished to do so, subject to the
1190
+ // following conditions:
1191
+ //
1192
+ // The above copyright notice and this permission notice shall be included
1193
+ // in all copies or substantial portions of the Software.
1194
+ //
1195
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1196
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1197
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1198
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1199
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1200
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1201
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
1202
+
3161
1203
  var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
3162
1204
  function getOwnPropertyDescriptors(obj) {
3163
1205
  var keys = Object.keys(obj);
@@ -3212,7 +1254,7 @@ var contentfulManagement = (function (exports) {
3212
1254
  // If --no-deprecation is set, then it is a no-op.
3213
1255
  function deprecate(fn, msg) {
3214
1256
  // Allow for deprecating things in the process of starting up.
3215
- if (isUndefined(global$1.process)) {
1257
+ if (isUndefined(global.process)) {
3216
1258
  return function() {
3217
1259
  return deprecate(fn, msg).apply(this, arguments);
3218
1260
  };
@@ -3652,7 +1694,7 @@ var contentfulManagement = (function (exports) {
3652
1694
  }
3653
1695
 
3654
1696
  function isBuffer(maybeBuf) {
3655
- return Buffer$1.isBuffer(maybeBuf);
1697
+ return Buffer.isBuffer(maybeBuf);
3656
1698
  }
3657
1699
 
3658
1700
  function objectToString(o) {
@@ -4136,7 +2178,7 @@ var contentfulManagement = (function (exports) {
4136
2178
  }
4137
2179
  if (
4138
2180
  (typeof globalThis !== 'undefined' && obj === globalThis)
4139
- || (typeof global$1 !== 'undefined' && obj === global$1)
2181
+ || (typeof global !== 'undefined' && obj === global)
4140
2182
  ) {
4141
2183
  return '{ [object globalThis] }';
4142
2184
  }
@@ -14544,8 +12586,6 @@ var contentfulManagement = (function (exports) {
14544
12586
  defaultHostnameUpload: 'upload.contentful.com',
14545
12587
  };
14546
12588
  class RestAdapter {
14547
- params;
14548
- axiosInstance;
14549
12589
  constructor(params) {
14550
12590
  if (!params.accessToken) {
14551
12591
  throw new TypeError('Expected parameter accessToken');
@@ -15614,7 +13654,6 @@ var contentfulManagement = (function (exports) {
15614
13654
  const DEFAULT_INITIAL_DELAY_MS = 1000;
15615
13655
  const DEFAULT_RETRY_INTERVAL_MS = 2000;
15616
13656
  class AsyncActionProcessingError extends Error {
15617
- action;
15618
13657
  constructor(message, action) {
15619
13658
  super(message);
15620
13659
  this.action = action;
@@ -25348,7 +23387,7 @@ var contentfulManagement = (function (exports) {
25348
23387
  const sdkMain = opts.type === 'plain' ? 'contentful-management-plain.js' : 'contentful-management.js';
25349
23388
  const userAgent = getUserAgentHeader(
25350
23389
  // @ts-expect-error
25351
- `${sdkMain}/${"11.64.0-new-beta.4"}`, params.application, params.integration, params.feature);
23390
+ `${sdkMain}/${"11.64.0-new-beta.5"}`, params.application, params.integration, params.feature);
25352
23391
  const adapter = createAdapter({ ...params, userAgent });
25353
23392
  // Parameters<?> and ReturnType<?> only return the types of the last overload
25354
23393
  // https://github.com/microsoft/TypeScript/issues/26591