@redhat-cloud-services/frontend-components-config-utilities 2.0.0 → 2.0.2

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