@blockend/widget 1.0.31 → 1.0.32
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.
- package/dist/AllRoutes-CPwuTwqd.js +2209 -0
- package/dist/Box-CIChapvH.js +55 -0
- package/dist/EstGas-CEFILtyf.js +12867 -0
- package/dist/Grow-DJZj9zjv.js +1656 -0
- package/dist/InputComp-DqF1JGIu.js +106 -0
- package/dist/LoadRoute-r3sHTYXM.js +126 -0
- package/dist/QuotesProgress-BXVLxZ8U.js +28 -0
- package/dist/SwapAsset-07WvVwl-.js +64 -0
- package/dist/Tooltip-CNAsCF8n.js +572 -0
- package/dist/TxnButton-D2TTkFYA.js +207 -0
- package/dist/WidgetForm.module-QHJ0-m5f.js +9 -0
- package/dist/{add-B8AfyNIx.js → add-t2GqC9VA.js} +3 -3
- package/dist/{all-wallets-BaLLU39i.js → all-wallets-DFyf0q31.js} +3 -3
- package/dist/{app-store-DNpoABj1.js → app-store-aAahwmBP.js} +3 -3
- package/dist/{apple-DzzHtaL4.js → apple-DeRgpwlc.js} +3 -3
- package/dist/{arrow-bottom-D2c13c51.js → arrow-bottom-DdEOkaAj.js} +3 -3
- package/dist/{arrow-bottom-circle-ls9OCLx1.js → arrow-bottom-circle-BWwREWcv.js} +3 -3
- package/dist/{arrow-left-BI3rQkNI.js → arrow-left-CulyLmoH.js} +3 -3
- package/dist/{arrow-right-rnMzhVod.js → arrow-right-Dwr7TISn.js} +3 -3
- package/dist/{arrow-top-CfA6PVMz.js → arrow-top-pL4rM_y8.js} +3 -3
- package/dist/{bank-CmpAmHgg.js → bank-CPuyK_08.js} +3 -3
- package/dist/basic-CVc9xEvb.js +5783 -0
- package/dist/{browser-mEcjgS1H.js → browser-Cbq2Zbp4.js} +3 -3
- package/dist/{card-DkgIWcMc.js → card-B_hUtPWK.js} +3 -3
- package/dist/ccip-BLVGcR4A.js +228 -0
- package/dist/{checkmark-B_A013n2.js → checkmark-WEqTsFAc.js} +3 -3
- package/dist/{checkmark-bold-DestuG2T.js → checkmark-bold-Du_ZvhqM.js} +3 -3
- package/dist/{chevron-bottom-Di3S86dj.js → chevron-bottom-C-s-lv4L.js} +3 -3
- package/dist/{chevron-left-A9Wj-3tj.js → chevron-left-C7NcRElx.js} +3 -3
- package/dist/{chevron-right-UFxJogOZ.js → chevron-right-CSzmAmdn.js} +3 -3
- package/dist/{chevron-top-BbZs3eaC.js → chevron-top-Dd99Wfel.js} +3 -3
- package/dist/{chrome-store-B4F6hJmy.js → chrome-store-C4p77Of0.js} +3 -3
- package/dist/{clock-BbAQ09uV.js → clock-Cib24qjH.js} +3 -3
- package/dist/clockIcon-C2W5xvyt.js +76 -0
- package/dist/{close-CY3oZP_D.js → close-BXjEkTvS.js} +3 -3
- package/dist/{coinPlaceholder-DpfsobZT.js → coinPlaceholder-BFNC7cQN.js} +3 -3
- package/dist/{compass-CHS7RZFk.js → compass-CXPX5Ycp.js} +3 -3
- package/dist/{copy-CEd4nGhs.js → copy-BEawMbmF.js} +3 -3
- package/dist/core-Bez9Ow7F.js +14967 -0
- package/dist/cursor-Cxq4Q9jk.js +7 -0
- package/dist/{cursor-transparent-Tm6k6Ws4.js → cursor-transparent-ZjJ0P2vr.js} +3 -3
- package/dist/{desktop-CrSyXZkL.js → desktop-BhZVovAp.js} +3 -3
- package/dist/{disconnect-BooT10E1.js → disconnect-AC-bffZO.js} +3 -3
- package/dist/{discord-B982Qaml.js → discord-dT97h-CC.js} +3 -3
- package/dist/down-DP56YSKp.js +606 -0
- package/dist/{etherscan-CFL0IcNl.js → etherscan-rYFRhRTM.js} +3 -3
- package/dist/ethertousd-CC_ezooz.js +6 -0
- package/dist/{exclamation-triangle-BBeGXYgt.js → exclamation-triangle-C-pCuC08.js} +3 -3
- package/dist/{extension-C5WqJw73.js → extension-BnqauLSn.js} +3 -3
- package/dist/{external-link-CcSxVDcd.js → external-link-M9D6e_F3.js} +3 -3
- package/dist/{facebook-DF0v9ED8.js → facebook-DHezcoD-.js} +3 -3
- package/dist/{farcaster-Boq7M4VK.js → farcaster-D0Ky-Imv.js} +3 -3
- package/dist/{filters-DfeymbPx.js → filters-B02NYLWq.js} +3 -3
- package/dist/getChainIds-CJd2TZYT.js +1888 -0
- package/dist/getCosmosAddress-DTZfw04G.js +9565 -0
- package/dist/{github-DQ8FV4bD.js → github-BzQkIMuE.js} +3 -3
- package/dist/{google-Dm8FDDZR.js → google-BpwCJ4Fs.js} +3 -3
- package/dist/hamburger-BzqwkUjE.js +3915 -0
- package/dist/{help-circle-CbgiAebR.js → help-circle-C0nOySHC.js} +3 -3
- package/dist/{id-CzqxUksI.js → id-DFP_kFd4.js} +3 -3
- package/dist/{image-CsCGTIN-.js → image-QiYOAGjM.js} +3 -3
- package/dist/index-CDq3vNnP.js +22 -0
- package/dist/index-CLzkn733.js +28223 -0
- package/dist/index-CjtwASJt.js +252 -0
- package/dist/index-CrC4B7xn.js +331 -0
- package/dist/index-D5hLIe-N.js +9 -0
- package/dist/index-DDk00SOL.js +159 -0
- package/dist/index-DTish3yr.js +1014 -0
- package/dist/index-DW3W7zaF.js +473 -0
- package/dist/index-DXdD3L9f.js +1460 -0
- package/dist/index-DaJ1272l.js +18613 -0
- package/dist/index-DxPp2gBS.js +992 -0
- package/dist/index-Dy_n2MPD.js +3010 -0
- package/dist/index-oc8HPfOF.js +13583 -0
- package/dist/index.es-Bsr7zP98.js +366 -0
- package/dist/index.es-C-j-Ghef.js +11678 -0
- package/dist/index.es.js +4 -4
- package/dist/{info-fKCfLW0k.js → info-BTLQJ-wd.js} +3 -3
- package/dist/{info-circle-Bt350Yzj.js → info-circle-Dla9169_.js} +3 -3
- package/dist/{lightbulb-BL9YBxiA.js → lightbulb-PN8DA_Wh.js} +3 -3
- package/dist/{mail-_g6CHQeQ.js → mail-BGYZut_4.js} +3 -3
- package/dist/{mobile-B-EQ4IcH.js → mobile-BM760ZzX.js} +3 -3
- package/dist/{more-C3rpOdUy.js → more-rHGnl2ck.js} +3 -3
- package/dist/{network-placeholder-D9Ak7Xj_.js → network-placeholder-CyQl-3_2.js} +3 -3
- package/dist/{nftPlaceholder-CIIm2V_o.js → nftPlaceholder-nuUJ8nKY.js} +3 -3
- package/dist/{off-DZjgI0eE.js → off-GYlwYDrT.js} +3 -3
- package/dist/{play-store-DvRnagoF.js → play-store-Ck01Ez1F.js} +3 -3
- package/dist/{plus-C2jN2huZ.js → plus-CQfXWgLw.js} +3 -3
- package/dist/{qr-code-B64HnZgi.js → qr-code-CyLVwLY7.js} +3 -3
- package/dist/{recycle-horizontal-CovcJGa_.js → recycle-horizontal-DvnWPcEQ.js} +3 -3
- package/dist/{refresh-J1Vw6QMA.js → refresh-BOxj8b2n.js} +3 -3
- package/dist/{reown-logo-BsXoZ3KT.js → reown-logo-D1iprOTg.js} +3 -3
- package/dist/{search-BC86wYXR.js → search-DrPaZPnc.js} +3 -3
- package/dist/secp256k1-DgmH1qVg.js +1251 -0
- package/dist/{send-BPA1bK5G.js → send-ybBREe4b.js} +3 -3
- package/dist/shareicon-D3Qj5j1T.js +262 -0
- package/dist/{sortDown-cDA6MpOw.js → sortDown-CjBaDQTU.js} +13 -13
- package/dist/{swapHorizontal-47_8ePle.js → swapHorizontal-BddjZdXK.js} +3 -3
- package/dist/{swapHorizontalBold-CJ7TzeQP.js → swapHorizontalBold-B6AWjPZ9.js} +3 -3
- package/dist/{swapHorizontalMedium-CTACgUR9.js → swapHorizontalMedium-CNacWoBn.js} +3 -3
- package/dist/{swapHorizontalRoundedBold-Ht3_LABp.js → swapHorizontalRoundedBold-B8VcPnqt.js} +3 -3
- package/dist/{swapVertical-DlS0V6DD.js → swapVertical-zY2BbSyQ.js} +3 -3
- package/dist/{telegram-UZ00kvIE.js → telegram-DS4l-8Oc.js} +3 -3
- package/dist/{three-dots-D9zVXr1j.js → three-dots-RctNqamK.js} +3 -3
- package/dist/truncate-D9t92mVX.js +7 -0
- package/dist/{twitch-CP6rpz4m.js → twitch-CJ0llIIH.js} +3 -3
- package/dist/{twitterIcon-Cm3I3FRU.js → twitterIcon-pgvN9-bP.js} +3 -3
- package/dist/unsupportedProp-BJVuEW_b.js +10 -0
- package/dist/useRegisterError-C_YLA1dw.js +9857 -0
- package/dist/validError-CDlJpg_f.js +6 -0
- package/dist/{verify-DuUE85WT.js → verify-BeZLo1Fq.js} +3 -3
- package/dist/{verify-filled-CfgydKPa.js → verify-filled-meyb7E16.js} +3 -3
- package/dist/w3m-modal-C-Jp9NVv.js +1471 -0
- package/dist/{wallet-BC2LSDlF.js → wallet-CFcOgSsz.js} +3 -3
- package/dist/{wallet-placeholder-DugEJ7xM.js → wallet-placeholder-CeUMILZq.js} +3 -3
- package/dist/{walletconnect-wayCaYfk.js → walletconnect-D6LB1PyC.js} +7 -9
- package/dist/{warning-circle-Cy9YuvwU.js → warning-circle-BRtzofvT.js} +3 -3
- package/dist/{x-jggPFiy-.js → x-DKQAOOh3.js} +3 -3
- package/package.json +1 -1
- package/dist/AllRoutes-Bdi5ZW8W.js +0 -2604
- package/dist/Box-e4gA-y_H.js +0 -60
- package/dist/EstGas-C5ihS0Mw.js +0 -17108
- package/dist/Grow-B4K-I-E-.js +0 -2212
- package/dist/InputComp-C_UUZxNU.js +0 -114
- package/dist/LoadRoute-CnDhVKdh.js +0 -142
- package/dist/QuotesProgress-DxgPgPJE.js +0 -29
- package/dist/SwapAsset-CmmuxeQF.js +0 -65
- package/dist/Tooltip-D8YjOOKU.js +0 -718
- package/dist/TxnButton-CF-TLZrD.js +0 -302
- package/dist/WidgetForm.module-DhUUlwZP.js +0 -13
- package/dist/basic-Cx2xxgd9.js +0 -7109
- package/dist/ccip-BKpquA5i.js +0 -250
- package/dist/clockIcon-jSNFFrLy.js +0 -76
- package/dist/core-C-gr9X18.js +0 -17217
- package/dist/cursor-BTtIlTHP.js +0 -7
- package/dist/down-DDk8OoJG.js +0 -809
- package/dist/ethertousd-BOknTgU4.js +0 -7
- package/dist/getChainIds-6iugk2h0.js +0 -2431
- package/dist/getCosmosAddress-BgD5iV6f.js +0 -13998
- package/dist/hamburger-BYe_G11E.js +0 -4562
- package/dist/index-BAmjBHYR.js +0 -1087
- package/dist/index-BxHeZ9IF.js +0 -543
- package/dist/index-C7cb2O7r.js +0 -16078
- package/dist/index-CF9p4S_X.js +0 -11
- package/dist/index-C_vo1L7p.js +0 -24384
- package/dist/index-Ch7w83dW.js +0 -4217
- package/dist/index-Crhenmgw.js +0 -188
- package/dist/index-Cz5Dosd2.js +0 -412
- package/dist/index-D5OnT-__.js +0 -35858
- package/dist/index-DArR1lwi.js +0 -1759
- package/dist/index-hEJSpZe-.js +0 -308
- package/dist/index-m2O0cbD8.js +0 -1883
- package/dist/index-sLx4Edw4.js +0 -22
- package/dist/index.es-DIbGJsfa.js +0 -475
- package/dist/index.es-t6sHlseh.js +0 -12916
- package/dist/secp256k1-BkBK0mD5.js +0 -1681
- package/dist/shareicon-C88Wx-AM.js +0 -314
- package/dist/truncate-DSxFWEga.js +0 -7
- package/dist/unsupportedProp-DkeDzLfM.js +0 -14
- package/dist/useRegisterError-W_UfecIN.js +0 -19288
- package/dist/validError-rariWQ7G.js +0 -14
- package/dist/w3m-modal-Bl-DPlah.js +0 -1721
package/dist/index-DArR1lwi.js
DELETED
@@ -1,1759 +0,0 @@
|
|
1
|
-
var buffer = {};
|
2
|
-
var base64Js = {};
|
3
|
-
base64Js.byteLength = byteLength;
|
4
|
-
base64Js.toByteArray = toByteArray;
|
5
|
-
base64Js.fromByteArray = fromByteArray;
|
6
|
-
var lookup = [];
|
7
|
-
var revLookup = [];
|
8
|
-
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
9
|
-
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
10
|
-
for (var i = 0, len = code.length; i < len; ++i) {
|
11
|
-
lookup[i] = code[i];
|
12
|
-
revLookup[code.charCodeAt(i)] = i;
|
13
|
-
}
|
14
|
-
revLookup["-".charCodeAt(0)] = 62;
|
15
|
-
revLookup["_".charCodeAt(0)] = 63;
|
16
|
-
function getLens(b64) {
|
17
|
-
var len = b64.length;
|
18
|
-
if (len % 4 > 0) {
|
19
|
-
throw new Error("Invalid string. Length must be a multiple of 4");
|
20
|
-
}
|
21
|
-
var validLen = b64.indexOf("=");
|
22
|
-
if (validLen === -1) validLen = len;
|
23
|
-
var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
|
24
|
-
return [validLen, placeHoldersLen];
|
25
|
-
}
|
26
|
-
function byteLength(b64) {
|
27
|
-
var lens = getLens(b64);
|
28
|
-
var validLen = lens[0];
|
29
|
-
var placeHoldersLen = lens[1];
|
30
|
-
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
31
|
-
}
|
32
|
-
function _byteLength(b64, validLen, placeHoldersLen) {
|
33
|
-
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
34
|
-
}
|
35
|
-
function toByteArray(b64) {
|
36
|
-
var tmp;
|
37
|
-
var lens = getLens(b64);
|
38
|
-
var validLen = lens[0];
|
39
|
-
var placeHoldersLen = lens[1];
|
40
|
-
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
41
|
-
var curByte = 0;
|
42
|
-
var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
43
|
-
var i;
|
44
|
-
for (i = 0; i < len; i += 4) {
|
45
|
-
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
46
|
-
arr[curByte++] = tmp >> 16 & 255;
|
47
|
-
arr[curByte++] = tmp >> 8 & 255;
|
48
|
-
arr[curByte++] = tmp & 255;
|
49
|
-
}
|
50
|
-
if (placeHoldersLen === 2) {
|
51
|
-
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
52
|
-
arr[curByte++] = tmp & 255;
|
53
|
-
}
|
54
|
-
if (placeHoldersLen === 1) {
|
55
|
-
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
56
|
-
arr[curByte++] = tmp >> 8 & 255;
|
57
|
-
arr[curByte++] = tmp & 255;
|
58
|
-
}
|
59
|
-
return arr;
|
60
|
-
}
|
61
|
-
function tripletToBase64(num) {
|
62
|
-
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
63
|
-
}
|
64
|
-
function encodeChunk(uint8, start, end) {
|
65
|
-
var tmp;
|
66
|
-
var output = [];
|
67
|
-
for (var i = start; i < end; i += 3) {
|
68
|
-
tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
|
69
|
-
output.push(tripletToBase64(tmp));
|
70
|
-
}
|
71
|
-
return output.join("");
|
72
|
-
}
|
73
|
-
function fromByteArray(uint8) {
|
74
|
-
var tmp;
|
75
|
-
var len = uint8.length;
|
76
|
-
var extraBytes = len % 3;
|
77
|
-
var parts = [];
|
78
|
-
var maxChunkLength = 16383;
|
79
|
-
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
80
|
-
parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
|
81
|
-
}
|
82
|
-
if (extraBytes === 1) {
|
83
|
-
tmp = uint8[len - 1];
|
84
|
-
parts.push(
|
85
|
-
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
86
|
-
);
|
87
|
-
} else if (extraBytes === 2) {
|
88
|
-
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
89
|
-
parts.push(
|
90
|
-
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
91
|
-
);
|
92
|
-
}
|
93
|
-
return parts.join("");
|
94
|
-
}
|
95
|
-
var ieee754 = {};
|
96
|
-
ieee754.read = function(buffer2, offset, isLE, mLen, nBytes) {
|
97
|
-
var e, m;
|
98
|
-
var eLen = nBytes * 8 - mLen - 1;
|
99
|
-
var eMax = (1 << eLen) - 1;
|
100
|
-
var eBias = eMax >> 1;
|
101
|
-
var nBits = -7;
|
102
|
-
var i = isLE ? nBytes - 1 : 0;
|
103
|
-
var d = isLE ? -1 : 1;
|
104
|
-
var s = buffer2[offset + i];
|
105
|
-
i += d;
|
106
|
-
e = s & (1 << -nBits) - 1;
|
107
|
-
s >>= -nBits;
|
108
|
-
nBits += eLen;
|
109
|
-
for (; nBits > 0; e = e * 256 + buffer2[offset + i], i += d, nBits -= 8) {
|
110
|
-
}
|
111
|
-
m = e & (1 << -nBits) - 1;
|
112
|
-
e >>= -nBits;
|
113
|
-
nBits += mLen;
|
114
|
-
for (; nBits > 0; m = m * 256 + buffer2[offset + i], i += d, nBits -= 8) {
|
115
|
-
}
|
116
|
-
if (e === 0) {
|
117
|
-
e = 1 - eBias;
|
118
|
-
} else if (e === eMax) {
|
119
|
-
return m ? NaN : (s ? -1 : 1) * Infinity;
|
120
|
-
} else {
|
121
|
-
m = m + Math.pow(2, mLen);
|
122
|
-
e = e - eBias;
|
123
|
-
}
|
124
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
125
|
-
};
|
126
|
-
ieee754.write = function(buffer2, value, offset, isLE, mLen, nBytes) {
|
127
|
-
var e, m, c;
|
128
|
-
var eLen = nBytes * 8 - mLen - 1;
|
129
|
-
var eMax = (1 << eLen) - 1;
|
130
|
-
var eBias = eMax >> 1;
|
131
|
-
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
132
|
-
var i = isLE ? 0 : nBytes - 1;
|
133
|
-
var d = isLE ? 1 : -1;
|
134
|
-
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
135
|
-
value = Math.abs(value);
|
136
|
-
if (isNaN(value) || value === Infinity) {
|
137
|
-
m = isNaN(value) ? 1 : 0;
|
138
|
-
e = eMax;
|
139
|
-
} else {
|
140
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
141
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
142
|
-
e--;
|
143
|
-
c *= 2;
|
144
|
-
}
|
145
|
-
if (e + eBias >= 1) {
|
146
|
-
value += rt / c;
|
147
|
-
} else {
|
148
|
-
value += rt * Math.pow(2, 1 - eBias);
|
149
|
-
}
|
150
|
-
if (value * c >= 2) {
|
151
|
-
e++;
|
152
|
-
c /= 2;
|
153
|
-
}
|
154
|
-
if (e + eBias >= eMax) {
|
155
|
-
m = 0;
|
156
|
-
e = eMax;
|
157
|
-
} else if (e + eBias >= 1) {
|
158
|
-
m = (value * c - 1) * Math.pow(2, mLen);
|
159
|
-
e = e + eBias;
|
160
|
-
} else {
|
161
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
162
|
-
e = 0;
|
163
|
-
}
|
164
|
-
}
|
165
|
-
for (; mLen >= 8; buffer2[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
166
|
-
}
|
167
|
-
e = e << mLen | m;
|
168
|
-
eLen += mLen;
|
169
|
-
for (; eLen > 0; buffer2[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
170
|
-
}
|
171
|
-
buffer2[offset + i - d] |= s * 128;
|
172
|
-
};
|
173
|
-
(function(exports) {
|
174
|
-
const base64 = base64Js;
|
175
|
-
const ieee754$1 = ieee754;
|
176
|
-
const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
177
|
-
exports.Buffer = Buffer2;
|
178
|
-
exports.SlowBuffer = SlowBuffer;
|
179
|
-
exports.INSPECT_MAX_BYTES = 50;
|
180
|
-
const K_MAX_LENGTH = 2147483647;
|
181
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
182
|
-
const { Uint8Array: GlobalUint8Array, ArrayBuffer: GlobalArrayBuffer, SharedArrayBuffer: GlobalSharedArrayBuffer } = globalThis;
|
183
|
-
Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
184
|
-
if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
185
|
-
}
|
186
|
-
function typedArraySupport() {
|
187
|
-
try {
|
188
|
-
const arr = new GlobalUint8Array(1);
|
189
|
-
const proto = { foo: function() {
|
190
|
-
return 42;
|
191
|
-
} };
|
192
|
-
Object.setPrototypeOf(proto, GlobalUint8Array.prototype);
|
193
|
-
Object.setPrototypeOf(arr, proto);
|
194
|
-
return arr.foo() === 42;
|
195
|
-
} catch (e) {
|
196
|
-
return false;
|
197
|
-
}
|
198
|
-
}
|
199
|
-
Object.defineProperty(Buffer2.prototype, "parent", {
|
200
|
-
enumerable: true,
|
201
|
-
get: function() {
|
202
|
-
if (!Buffer2.isBuffer(this)) return void 0;
|
203
|
-
return this.buffer;
|
204
|
-
}
|
205
|
-
});
|
206
|
-
Object.defineProperty(Buffer2.prototype, "offset", {
|
207
|
-
enumerable: true,
|
208
|
-
get: function() {
|
209
|
-
if (!Buffer2.isBuffer(this)) return void 0;
|
210
|
-
return this.byteOffset;
|
211
|
-
}
|
212
|
-
});
|
213
|
-
function createBuffer(length) {
|
214
|
-
if (length > K_MAX_LENGTH) {
|
215
|
-
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
216
|
-
}
|
217
|
-
const buf = new GlobalUint8Array(length);
|
218
|
-
Object.setPrototypeOf(buf, Buffer2.prototype);
|
219
|
-
return buf;
|
220
|
-
}
|
221
|
-
function Buffer2(arg, encodingOrOffset, length) {
|
222
|
-
if (typeof arg === "number") {
|
223
|
-
if (typeof encodingOrOffset === "string") {
|
224
|
-
throw new TypeError(
|
225
|
-
'The "string" argument must be of type string. Received type number'
|
226
|
-
);
|
227
|
-
}
|
228
|
-
return allocUnsafe(arg);
|
229
|
-
}
|
230
|
-
return from(arg, encodingOrOffset, length);
|
231
|
-
}
|
232
|
-
Buffer2.poolSize = 8192;
|
233
|
-
function from(value, encodingOrOffset, length) {
|
234
|
-
if (typeof value === "string") {
|
235
|
-
return fromString(value, encodingOrOffset);
|
236
|
-
}
|
237
|
-
if (GlobalArrayBuffer.isView(value)) {
|
238
|
-
return fromArrayView(value);
|
239
|
-
}
|
240
|
-
if (value == null) {
|
241
|
-
throw new TypeError(
|
242
|
-
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
243
|
-
);
|
244
|
-
}
|
245
|
-
if (isInstance(value, GlobalArrayBuffer) || value && isInstance(value.buffer, GlobalArrayBuffer)) {
|
246
|
-
return fromArrayBuffer(value, encodingOrOffset, length);
|
247
|
-
}
|
248
|
-
if (typeof GlobalSharedArrayBuffer !== "undefined" && (isInstance(value, GlobalSharedArrayBuffer) || value && isInstance(value.buffer, GlobalSharedArrayBuffer))) {
|
249
|
-
return fromArrayBuffer(value, encodingOrOffset, length);
|
250
|
-
}
|
251
|
-
if (typeof value === "number") {
|
252
|
-
throw new TypeError(
|
253
|
-
'The "value" argument must not be of type number. Received type number'
|
254
|
-
);
|
255
|
-
}
|
256
|
-
const valueOf = value.valueOf && value.valueOf();
|
257
|
-
if (valueOf != null && valueOf !== value) {
|
258
|
-
return Buffer2.from(valueOf, encodingOrOffset, length);
|
259
|
-
}
|
260
|
-
const b = fromObject(value);
|
261
|
-
if (b) return b;
|
262
|
-
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
263
|
-
return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
264
|
-
}
|
265
|
-
throw new TypeError(
|
266
|
-
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
267
|
-
);
|
268
|
-
}
|
269
|
-
Buffer2.from = function(value, encodingOrOffset, length) {
|
270
|
-
return from(value, encodingOrOffset, length);
|
271
|
-
};
|
272
|
-
Object.setPrototypeOf(Buffer2.prototype, GlobalUint8Array.prototype);
|
273
|
-
Object.setPrototypeOf(Buffer2, GlobalUint8Array);
|
274
|
-
function assertSize(size) {
|
275
|
-
if (typeof size !== "number") {
|
276
|
-
throw new TypeError('"size" argument must be of type number');
|
277
|
-
} else if (size < 0) {
|
278
|
-
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
279
|
-
}
|
280
|
-
}
|
281
|
-
function alloc(size, fill, encoding) {
|
282
|
-
assertSize(size);
|
283
|
-
if (size <= 0) {
|
284
|
-
return createBuffer(size);
|
285
|
-
}
|
286
|
-
if (fill !== void 0) {
|
287
|
-
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
|
288
|
-
}
|
289
|
-
return createBuffer(size);
|
290
|
-
}
|
291
|
-
Buffer2.alloc = function(size, fill, encoding) {
|
292
|
-
return alloc(size, fill, encoding);
|
293
|
-
};
|
294
|
-
function allocUnsafe(size) {
|
295
|
-
assertSize(size);
|
296
|
-
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
297
|
-
}
|
298
|
-
Buffer2.allocUnsafe = function(size) {
|
299
|
-
return allocUnsafe(size);
|
300
|
-
};
|
301
|
-
Buffer2.allocUnsafeSlow = function(size) {
|
302
|
-
return allocUnsafe(size);
|
303
|
-
};
|
304
|
-
function fromString(string, encoding) {
|
305
|
-
if (typeof encoding !== "string" || encoding === "") {
|
306
|
-
encoding = "utf8";
|
307
|
-
}
|
308
|
-
if (!Buffer2.isEncoding(encoding)) {
|
309
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
310
|
-
}
|
311
|
-
const length = byteLength2(string, encoding) | 0;
|
312
|
-
let buf = createBuffer(length);
|
313
|
-
const actual = buf.write(string, encoding);
|
314
|
-
if (actual !== length) {
|
315
|
-
buf = buf.slice(0, actual);
|
316
|
-
}
|
317
|
-
return buf;
|
318
|
-
}
|
319
|
-
function fromArrayLike(array) {
|
320
|
-
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
321
|
-
const buf = createBuffer(length);
|
322
|
-
for (let i = 0; i < length; i += 1) {
|
323
|
-
buf[i] = array[i] & 255;
|
324
|
-
}
|
325
|
-
return buf;
|
326
|
-
}
|
327
|
-
function fromArrayView(arrayView) {
|
328
|
-
if (isInstance(arrayView, GlobalUint8Array)) {
|
329
|
-
const copy = new GlobalUint8Array(arrayView);
|
330
|
-
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
331
|
-
}
|
332
|
-
return fromArrayLike(arrayView);
|
333
|
-
}
|
334
|
-
function fromArrayBuffer(array, byteOffset, length) {
|
335
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
336
|
-
throw new RangeError('"offset" is outside of buffer bounds');
|
337
|
-
}
|
338
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
339
|
-
throw new RangeError('"length" is outside of buffer bounds');
|
340
|
-
}
|
341
|
-
let buf;
|
342
|
-
if (byteOffset === void 0 && length === void 0) {
|
343
|
-
buf = new GlobalUint8Array(array);
|
344
|
-
} else if (length === void 0) {
|
345
|
-
buf = new GlobalUint8Array(array, byteOffset);
|
346
|
-
} else {
|
347
|
-
buf = new GlobalUint8Array(array, byteOffset, length);
|
348
|
-
}
|
349
|
-
Object.setPrototypeOf(buf, Buffer2.prototype);
|
350
|
-
return buf;
|
351
|
-
}
|
352
|
-
function fromObject(obj) {
|
353
|
-
if (Buffer2.isBuffer(obj)) {
|
354
|
-
const len = checked(obj.length) | 0;
|
355
|
-
const buf = createBuffer(len);
|
356
|
-
if (buf.length === 0) {
|
357
|
-
return buf;
|
358
|
-
}
|
359
|
-
obj.copy(buf, 0, 0, len);
|
360
|
-
return buf;
|
361
|
-
}
|
362
|
-
if (obj.length !== void 0) {
|
363
|
-
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
364
|
-
return createBuffer(0);
|
365
|
-
}
|
366
|
-
return fromArrayLike(obj);
|
367
|
-
}
|
368
|
-
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
369
|
-
return fromArrayLike(obj.data);
|
370
|
-
}
|
371
|
-
}
|
372
|
-
function checked(length) {
|
373
|
-
if (length >= K_MAX_LENGTH) {
|
374
|
-
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
375
|
-
}
|
376
|
-
return length | 0;
|
377
|
-
}
|
378
|
-
function SlowBuffer(length) {
|
379
|
-
if (+length != length) {
|
380
|
-
length = 0;
|
381
|
-
}
|
382
|
-
return Buffer2.alloc(+length);
|
383
|
-
}
|
384
|
-
Buffer2.isBuffer = function isBuffer(b) {
|
385
|
-
return b != null && b._isBuffer === true && b !== Buffer2.prototype;
|
386
|
-
};
|
387
|
-
Buffer2.compare = function compare(a, b) {
|
388
|
-
if (isInstance(a, GlobalUint8Array)) a = Buffer2.from(a, a.offset, a.byteLength);
|
389
|
-
if (isInstance(b, GlobalUint8Array)) b = Buffer2.from(b, b.offset, b.byteLength);
|
390
|
-
if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
|
391
|
-
throw new TypeError(
|
392
|
-
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
393
|
-
);
|
394
|
-
}
|
395
|
-
if (a === b) return 0;
|
396
|
-
let x = a.length;
|
397
|
-
let y = b.length;
|
398
|
-
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
399
|
-
if (a[i] !== b[i]) {
|
400
|
-
x = a[i];
|
401
|
-
y = b[i];
|
402
|
-
break;
|
403
|
-
}
|
404
|
-
}
|
405
|
-
if (x < y) return -1;
|
406
|
-
if (y < x) return 1;
|
407
|
-
return 0;
|
408
|
-
};
|
409
|
-
Buffer2.isEncoding = function isEncoding(encoding) {
|
410
|
-
switch (String(encoding).toLowerCase()) {
|
411
|
-
case "hex":
|
412
|
-
case "utf8":
|
413
|
-
case "utf-8":
|
414
|
-
case "ascii":
|
415
|
-
case "latin1":
|
416
|
-
case "binary":
|
417
|
-
case "base64":
|
418
|
-
case "ucs2":
|
419
|
-
case "ucs-2":
|
420
|
-
case "utf16le":
|
421
|
-
case "utf-16le":
|
422
|
-
return true;
|
423
|
-
default:
|
424
|
-
return false;
|
425
|
-
}
|
426
|
-
};
|
427
|
-
Buffer2.concat = function concat(list, length) {
|
428
|
-
if (!Array.isArray(list)) {
|
429
|
-
throw new TypeError('"list" argument must be an Array of Buffers');
|
430
|
-
}
|
431
|
-
if (list.length === 0) {
|
432
|
-
return Buffer2.alloc(0);
|
433
|
-
}
|
434
|
-
let i;
|
435
|
-
if (length === void 0) {
|
436
|
-
length = 0;
|
437
|
-
for (i = 0; i < list.length; ++i) {
|
438
|
-
length += list[i].length;
|
439
|
-
}
|
440
|
-
}
|
441
|
-
const buffer2 = Buffer2.allocUnsafe(length);
|
442
|
-
let pos = 0;
|
443
|
-
for (i = 0; i < list.length; ++i) {
|
444
|
-
let buf = list[i];
|
445
|
-
if (isInstance(buf, GlobalUint8Array)) {
|
446
|
-
if (pos + buf.length > buffer2.length) {
|
447
|
-
if (!Buffer2.isBuffer(buf)) buf = Buffer2.from(buf);
|
448
|
-
buf.copy(buffer2, pos);
|
449
|
-
} else {
|
450
|
-
GlobalUint8Array.prototype.set.call(
|
451
|
-
buffer2,
|
452
|
-
buf,
|
453
|
-
pos
|
454
|
-
);
|
455
|
-
}
|
456
|
-
} else if (!Buffer2.isBuffer(buf)) {
|
457
|
-
throw new TypeError('"list" argument must be an Array of Buffers');
|
458
|
-
} else {
|
459
|
-
buf.copy(buffer2, pos);
|
460
|
-
}
|
461
|
-
pos += buf.length;
|
462
|
-
}
|
463
|
-
return buffer2;
|
464
|
-
};
|
465
|
-
function byteLength2(string, encoding) {
|
466
|
-
if (Buffer2.isBuffer(string)) {
|
467
|
-
return string.length;
|
468
|
-
}
|
469
|
-
if (GlobalArrayBuffer.isView(string) || isInstance(string, GlobalArrayBuffer)) {
|
470
|
-
return string.byteLength;
|
471
|
-
}
|
472
|
-
if (typeof string !== "string") {
|
473
|
-
throw new TypeError(
|
474
|
-
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
|
475
|
-
);
|
476
|
-
}
|
477
|
-
const len = string.length;
|
478
|
-
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
479
|
-
if (!mustMatch && len === 0) return 0;
|
480
|
-
let loweredCase = false;
|
481
|
-
for (; ; ) {
|
482
|
-
switch (encoding) {
|
483
|
-
case "ascii":
|
484
|
-
case "latin1":
|
485
|
-
case "binary":
|
486
|
-
return len;
|
487
|
-
case "utf8":
|
488
|
-
case "utf-8":
|
489
|
-
return utf8ToBytes(string).length;
|
490
|
-
case "ucs2":
|
491
|
-
case "ucs-2":
|
492
|
-
case "utf16le":
|
493
|
-
case "utf-16le":
|
494
|
-
return len * 2;
|
495
|
-
case "hex":
|
496
|
-
return len >>> 1;
|
497
|
-
case "base64":
|
498
|
-
return base64ToBytes(string).length;
|
499
|
-
default:
|
500
|
-
if (loweredCase) {
|
501
|
-
return mustMatch ? -1 : utf8ToBytes(string).length;
|
502
|
-
}
|
503
|
-
encoding = ("" + encoding).toLowerCase();
|
504
|
-
loweredCase = true;
|
505
|
-
}
|
506
|
-
}
|
507
|
-
}
|
508
|
-
Buffer2.byteLength = byteLength2;
|
509
|
-
function slowToString(encoding, start, end) {
|
510
|
-
let loweredCase = false;
|
511
|
-
if (start === void 0 || start < 0) {
|
512
|
-
start = 0;
|
513
|
-
}
|
514
|
-
if (start > this.length) {
|
515
|
-
return "";
|
516
|
-
}
|
517
|
-
if (end === void 0 || end > this.length) {
|
518
|
-
end = this.length;
|
519
|
-
}
|
520
|
-
if (end <= 0) {
|
521
|
-
return "";
|
522
|
-
}
|
523
|
-
end >>>= 0;
|
524
|
-
start >>>= 0;
|
525
|
-
if (end <= start) {
|
526
|
-
return "";
|
527
|
-
}
|
528
|
-
if (!encoding) encoding = "utf8";
|
529
|
-
while (true) {
|
530
|
-
switch (encoding) {
|
531
|
-
case "hex":
|
532
|
-
return hexSlice(this, start, end);
|
533
|
-
case "utf8":
|
534
|
-
case "utf-8":
|
535
|
-
return utf8Slice(this, start, end);
|
536
|
-
case "ascii":
|
537
|
-
return asciiSlice(this, start, end);
|
538
|
-
case "latin1":
|
539
|
-
case "binary":
|
540
|
-
return latin1Slice(this, start, end);
|
541
|
-
case "base64":
|
542
|
-
return base64Slice(this, start, end);
|
543
|
-
case "ucs2":
|
544
|
-
case "ucs-2":
|
545
|
-
case "utf16le":
|
546
|
-
case "utf-16le":
|
547
|
-
return utf16leSlice(this, start, end);
|
548
|
-
default:
|
549
|
-
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
550
|
-
encoding = (encoding + "").toLowerCase();
|
551
|
-
loweredCase = true;
|
552
|
-
}
|
553
|
-
}
|
554
|
-
}
|
555
|
-
Buffer2.prototype._isBuffer = true;
|
556
|
-
function swap(b, n, m) {
|
557
|
-
const i = b[n];
|
558
|
-
b[n] = b[m];
|
559
|
-
b[m] = i;
|
560
|
-
}
|
561
|
-
Buffer2.prototype.swap16 = function swap16() {
|
562
|
-
const len = this.length;
|
563
|
-
if (len % 2 !== 0) {
|
564
|
-
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
565
|
-
}
|
566
|
-
for (let i = 0; i < len; i += 2) {
|
567
|
-
swap(this, i, i + 1);
|
568
|
-
}
|
569
|
-
return this;
|
570
|
-
};
|
571
|
-
Buffer2.prototype.swap32 = function swap32() {
|
572
|
-
const len = this.length;
|
573
|
-
if (len % 4 !== 0) {
|
574
|
-
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
575
|
-
}
|
576
|
-
for (let i = 0; i < len; i += 4) {
|
577
|
-
swap(this, i, i + 3);
|
578
|
-
swap(this, i + 1, i + 2);
|
579
|
-
}
|
580
|
-
return this;
|
581
|
-
};
|
582
|
-
Buffer2.prototype.swap64 = function swap64() {
|
583
|
-
const len = this.length;
|
584
|
-
if (len % 8 !== 0) {
|
585
|
-
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
586
|
-
}
|
587
|
-
for (let i = 0; i < len; i += 8) {
|
588
|
-
swap(this, i, i + 7);
|
589
|
-
swap(this, i + 1, i + 6);
|
590
|
-
swap(this, i + 2, i + 5);
|
591
|
-
swap(this, i + 3, i + 4);
|
592
|
-
}
|
593
|
-
return this;
|
594
|
-
};
|
595
|
-
Buffer2.prototype.toString = function toString() {
|
596
|
-
const length = this.length;
|
597
|
-
if (length === 0) return "";
|
598
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
599
|
-
return slowToString.apply(this, arguments);
|
600
|
-
};
|
601
|
-
Buffer2.prototype.toLocaleString = Buffer2.prototype.toString;
|
602
|
-
Buffer2.prototype.equals = function equals(b) {
|
603
|
-
if (!Buffer2.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
604
|
-
if (this === b) return true;
|
605
|
-
return Buffer2.compare(this, b) === 0;
|
606
|
-
};
|
607
|
-
Buffer2.prototype.inspect = function inspect() {
|
608
|
-
let str = "";
|
609
|
-
const max = exports.INSPECT_MAX_BYTES;
|
610
|
-
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
611
|
-
if (this.length > max) str += " ... ";
|
612
|
-
return "<Buffer " + str + ">";
|
613
|
-
};
|
614
|
-
if (customInspectSymbol) {
|
615
|
-
Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect;
|
616
|
-
}
|
617
|
-
Buffer2.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
618
|
-
if (isInstance(target, GlobalUint8Array)) {
|
619
|
-
target = Buffer2.from(target, target.offset, target.byteLength);
|
620
|
-
}
|
621
|
-
if (!Buffer2.isBuffer(target)) {
|
622
|
-
throw new TypeError(
|
623
|
-
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
624
|
-
);
|
625
|
-
}
|
626
|
-
if (start === void 0) {
|
627
|
-
start = 0;
|
628
|
-
}
|
629
|
-
if (end === void 0) {
|
630
|
-
end = target ? target.length : 0;
|
631
|
-
}
|
632
|
-
if (thisStart === void 0) {
|
633
|
-
thisStart = 0;
|
634
|
-
}
|
635
|
-
if (thisEnd === void 0) {
|
636
|
-
thisEnd = this.length;
|
637
|
-
}
|
638
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
639
|
-
throw new RangeError("out of range index");
|
640
|
-
}
|
641
|
-
if (thisStart >= thisEnd && start >= end) {
|
642
|
-
return 0;
|
643
|
-
}
|
644
|
-
if (thisStart >= thisEnd) {
|
645
|
-
return -1;
|
646
|
-
}
|
647
|
-
if (start >= end) {
|
648
|
-
return 1;
|
649
|
-
}
|
650
|
-
start >>>= 0;
|
651
|
-
end >>>= 0;
|
652
|
-
thisStart >>>= 0;
|
653
|
-
thisEnd >>>= 0;
|
654
|
-
if (this === target) return 0;
|
655
|
-
let x = thisEnd - thisStart;
|
656
|
-
let y = end - start;
|
657
|
-
const len = Math.min(x, y);
|
658
|
-
const thisCopy = this.slice(thisStart, thisEnd);
|
659
|
-
const targetCopy = target.slice(start, end);
|
660
|
-
for (let i = 0; i < len; ++i) {
|
661
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
662
|
-
x = thisCopy[i];
|
663
|
-
y = targetCopy[i];
|
664
|
-
break;
|
665
|
-
}
|
666
|
-
}
|
667
|
-
if (x < y) return -1;
|
668
|
-
if (y < x) return 1;
|
669
|
-
return 0;
|
670
|
-
};
|
671
|
-
function bidirectionalIndexOf(buffer2, val, byteOffset, encoding, dir) {
|
672
|
-
if (buffer2.length === 0) return -1;
|
673
|
-
if (typeof byteOffset === "string") {
|
674
|
-
encoding = byteOffset;
|
675
|
-
byteOffset = 0;
|
676
|
-
} else if (byteOffset > 2147483647) {
|
677
|
-
byteOffset = 2147483647;
|
678
|
-
} else if (byteOffset < -2147483648) {
|
679
|
-
byteOffset = -2147483648;
|
680
|
-
}
|
681
|
-
byteOffset = +byteOffset;
|
682
|
-
if (numberIsNaN(byteOffset)) {
|
683
|
-
byteOffset = dir ? 0 : buffer2.length - 1;
|
684
|
-
}
|
685
|
-
if (byteOffset < 0) byteOffset = buffer2.length + byteOffset;
|
686
|
-
if (byteOffset >= buffer2.length) {
|
687
|
-
if (dir) return -1;
|
688
|
-
else byteOffset = buffer2.length - 1;
|
689
|
-
} else if (byteOffset < 0) {
|
690
|
-
if (dir) byteOffset = 0;
|
691
|
-
else return -1;
|
692
|
-
}
|
693
|
-
if (typeof val === "string") {
|
694
|
-
val = Buffer2.from(val, encoding);
|
695
|
-
}
|
696
|
-
if (Buffer2.isBuffer(val)) {
|
697
|
-
if (val.length === 0) {
|
698
|
-
return -1;
|
699
|
-
}
|
700
|
-
return arrayIndexOf(buffer2, val, byteOffset, encoding, dir);
|
701
|
-
} else if (typeof val === "number") {
|
702
|
-
val = val & 255;
|
703
|
-
if (typeof GlobalUint8Array.prototype.indexOf === "function") {
|
704
|
-
if (dir) {
|
705
|
-
return GlobalUint8Array.prototype.indexOf.call(buffer2, val, byteOffset);
|
706
|
-
} else {
|
707
|
-
return GlobalUint8Array.prototype.lastIndexOf.call(buffer2, val, byteOffset);
|
708
|
-
}
|
709
|
-
}
|
710
|
-
return arrayIndexOf(buffer2, [val], byteOffset, encoding, dir);
|
711
|
-
}
|
712
|
-
throw new TypeError("val must be string, number or Buffer");
|
713
|
-
}
|
714
|
-
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
715
|
-
let indexSize = 1;
|
716
|
-
let arrLength = arr.length;
|
717
|
-
let valLength = val.length;
|
718
|
-
if (encoding !== void 0) {
|
719
|
-
encoding = String(encoding).toLowerCase();
|
720
|
-
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
721
|
-
if (arr.length < 2 || val.length < 2) {
|
722
|
-
return -1;
|
723
|
-
}
|
724
|
-
indexSize = 2;
|
725
|
-
arrLength /= 2;
|
726
|
-
valLength /= 2;
|
727
|
-
byteOffset /= 2;
|
728
|
-
}
|
729
|
-
}
|
730
|
-
function read(buf, i2) {
|
731
|
-
if (indexSize === 1) {
|
732
|
-
return buf[i2];
|
733
|
-
} else {
|
734
|
-
return buf.readUInt16BE(i2 * indexSize);
|
735
|
-
}
|
736
|
-
}
|
737
|
-
let i;
|
738
|
-
if (dir) {
|
739
|
-
let foundIndex = -1;
|
740
|
-
for (i = byteOffset; i < arrLength; i++) {
|
741
|
-
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
742
|
-
if (foundIndex === -1) foundIndex = i;
|
743
|
-
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
744
|
-
} else {
|
745
|
-
if (foundIndex !== -1) i -= i - foundIndex;
|
746
|
-
foundIndex = -1;
|
747
|
-
}
|
748
|
-
}
|
749
|
-
} else {
|
750
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
751
|
-
for (i = byteOffset; i >= 0; i--) {
|
752
|
-
let found = true;
|
753
|
-
for (let j = 0; j < valLength; j++) {
|
754
|
-
if (read(arr, i + j) !== read(val, j)) {
|
755
|
-
found = false;
|
756
|
-
break;
|
757
|
-
}
|
758
|
-
}
|
759
|
-
if (found) return i;
|
760
|
-
}
|
761
|
-
}
|
762
|
-
return -1;
|
763
|
-
}
|
764
|
-
Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
|
765
|
-
return this.indexOf(val, byteOffset, encoding) !== -1;
|
766
|
-
};
|
767
|
-
Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
768
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
769
|
-
};
|
770
|
-
Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
771
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
772
|
-
};
|
773
|
-
function hexWrite(buf, string, offset, length) {
|
774
|
-
offset = Number(offset) || 0;
|
775
|
-
const remaining = buf.length - offset;
|
776
|
-
if (!length) {
|
777
|
-
length = remaining;
|
778
|
-
} else {
|
779
|
-
length = Number(length);
|
780
|
-
if (length > remaining) {
|
781
|
-
length = remaining;
|
782
|
-
}
|
783
|
-
}
|
784
|
-
const strLen = string.length;
|
785
|
-
if (length > strLen / 2) {
|
786
|
-
length = strLen / 2;
|
787
|
-
}
|
788
|
-
let i;
|
789
|
-
for (i = 0; i < length; ++i) {
|
790
|
-
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
791
|
-
if (numberIsNaN(parsed)) return i;
|
792
|
-
buf[offset + i] = parsed;
|
793
|
-
}
|
794
|
-
return i;
|
795
|
-
}
|
796
|
-
function utf8Write(buf, string, offset, length) {
|
797
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
798
|
-
}
|
799
|
-
function asciiWrite(buf, string, offset, length) {
|
800
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
801
|
-
}
|
802
|
-
function base64Write(buf, string, offset, length) {
|
803
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
804
|
-
}
|
805
|
-
function ucs2Write(buf, string, offset, length) {
|
806
|
-
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
807
|
-
}
|
808
|
-
Buffer2.prototype.write = function write(string, offset, length, encoding) {
|
809
|
-
if (offset === void 0) {
|
810
|
-
encoding = "utf8";
|
811
|
-
length = this.length;
|
812
|
-
offset = 0;
|
813
|
-
} else if (length === void 0 && typeof offset === "string") {
|
814
|
-
encoding = offset;
|
815
|
-
length = this.length;
|
816
|
-
offset = 0;
|
817
|
-
} else if (isFinite(offset)) {
|
818
|
-
offset = offset >>> 0;
|
819
|
-
if (isFinite(length)) {
|
820
|
-
length = length >>> 0;
|
821
|
-
if (encoding === void 0) encoding = "utf8";
|
822
|
-
} else {
|
823
|
-
encoding = length;
|
824
|
-
length = void 0;
|
825
|
-
}
|
826
|
-
} else {
|
827
|
-
throw new Error(
|
828
|
-
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
829
|
-
);
|
830
|
-
}
|
831
|
-
const remaining = this.length - offset;
|
832
|
-
if (length === void 0 || length > remaining) length = remaining;
|
833
|
-
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
834
|
-
throw new RangeError("Attempt to write outside buffer bounds");
|
835
|
-
}
|
836
|
-
if (!encoding) encoding = "utf8";
|
837
|
-
let loweredCase = false;
|
838
|
-
for (; ; ) {
|
839
|
-
switch (encoding) {
|
840
|
-
case "hex":
|
841
|
-
return hexWrite(this, string, offset, length);
|
842
|
-
case "utf8":
|
843
|
-
case "utf-8":
|
844
|
-
return utf8Write(this, string, offset, length);
|
845
|
-
case "ascii":
|
846
|
-
case "latin1":
|
847
|
-
case "binary":
|
848
|
-
return asciiWrite(this, string, offset, length);
|
849
|
-
case "base64":
|
850
|
-
return base64Write(this, string, offset, length);
|
851
|
-
case "ucs2":
|
852
|
-
case "ucs-2":
|
853
|
-
case "utf16le":
|
854
|
-
case "utf-16le":
|
855
|
-
return ucs2Write(this, string, offset, length);
|
856
|
-
default:
|
857
|
-
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
858
|
-
encoding = ("" + encoding).toLowerCase();
|
859
|
-
loweredCase = true;
|
860
|
-
}
|
861
|
-
}
|
862
|
-
};
|
863
|
-
Buffer2.prototype.toJSON = function toJSON() {
|
864
|
-
return {
|
865
|
-
type: "Buffer",
|
866
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
867
|
-
};
|
868
|
-
};
|
869
|
-
function base64Slice(buf, start, end) {
|
870
|
-
if (start === 0 && end === buf.length) {
|
871
|
-
return base64.fromByteArray(buf);
|
872
|
-
} else {
|
873
|
-
return base64.fromByteArray(buf.slice(start, end));
|
874
|
-
}
|
875
|
-
}
|
876
|
-
function utf8Slice(buf, start, end) {
|
877
|
-
end = Math.min(buf.length, end);
|
878
|
-
const res = [];
|
879
|
-
let i = start;
|
880
|
-
while (i < end) {
|
881
|
-
const firstByte = buf[i];
|
882
|
-
let codePoint = null;
|
883
|
-
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
884
|
-
if (i + bytesPerSequence <= end) {
|
885
|
-
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
886
|
-
switch (bytesPerSequence) {
|
887
|
-
case 1:
|
888
|
-
if (firstByte < 128) {
|
889
|
-
codePoint = firstByte;
|
890
|
-
}
|
891
|
-
break;
|
892
|
-
case 2:
|
893
|
-
secondByte = buf[i + 1];
|
894
|
-
if ((secondByte & 192) === 128) {
|
895
|
-
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
896
|
-
if (tempCodePoint > 127) {
|
897
|
-
codePoint = tempCodePoint;
|
898
|
-
}
|
899
|
-
}
|
900
|
-
break;
|
901
|
-
case 3:
|
902
|
-
secondByte = buf[i + 1];
|
903
|
-
thirdByte = buf[i + 2];
|
904
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
905
|
-
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
906
|
-
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
907
|
-
codePoint = tempCodePoint;
|
908
|
-
}
|
909
|
-
}
|
910
|
-
break;
|
911
|
-
case 4:
|
912
|
-
secondByte = buf[i + 1];
|
913
|
-
thirdByte = buf[i + 2];
|
914
|
-
fourthByte = buf[i + 3];
|
915
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
916
|
-
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
917
|
-
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
918
|
-
codePoint = tempCodePoint;
|
919
|
-
}
|
920
|
-
}
|
921
|
-
}
|
922
|
-
}
|
923
|
-
if (codePoint === null) {
|
924
|
-
codePoint = 65533;
|
925
|
-
bytesPerSequence = 1;
|
926
|
-
} else if (codePoint > 65535) {
|
927
|
-
codePoint -= 65536;
|
928
|
-
res.push(codePoint >>> 10 & 1023 | 55296);
|
929
|
-
codePoint = 56320 | codePoint & 1023;
|
930
|
-
}
|
931
|
-
res.push(codePoint);
|
932
|
-
i += bytesPerSequence;
|
933
|
-
}
|
934
|
-
return decodeCodePointsArray(res);
|
935
|
-
}
|
936
|
-
const MAX_ARGUMENTS_LENGTH = 4096;
|
937
|
-
function decodeCodePointsArray(codePoints) {
|
938
|
-
const len = codePoints.length;
|
939
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
940
|
-
return String.fromCharCode.apply(String, codePoints);
|
941
|
-
}
|
942
|
-
let res = "";
|
943
|
-
let i = 0;
|
944
|
-
while (i < len) {
|
945
|
-
res += String.fromCharCode.apply(
|
946
|
-
String,
|
947
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
948
|
-
);
|
949
|
-
}
|
950
|
-
return res;
|
951
|
-
}
|
952
|
-
function asciiSlice(buf, start, end) {
|
953
|
-
let ret = "";
|
954
|
-
end = Math.min(buf.length, end);
|
955
|
-
for (let i = start; i < end; ++i) {
|
956
|
-
ret += String.fromCharCode(buf[i] & 127);
|
957
|
-
}
|
958
|
-
return ret;
|
959
|
-
}
|
960
|
-
function latin1Slice(buf, start, end) {
|
961
|
-
let ret = "";
|
962
|
-
end = Math.min(buf.length, end);
|
963
|
-
for (let i = start; i < end; ++i) {
|
964
|
-
ret += String.fromCharCode(buf[i]);
|
965
|
-
}
|
966
|
-
return ret;
|
967
|
-
}
|
968
|
-
function hexSlice(buf, start, end) {
|
969
|
-
const len = buf.length;
|
970
|
-
if (!start || start < 0) start = 0;
|
971
|
-
if (!end || end < 0 || end > len) end = len;
|
972
|
-
let out = "";
|
973
|
-
for (let i = start; i < end; ++i) {
|
974
|
-
out += hexSliceLookupTable[buf[i]];
|
975
|
-
}
|
976
|
-
return out;
|
977
|
-
}
|
978
|
-
function utf16leSlice(buf, start, end) {
|
979
|
-
const bytes = buf.slice(start, end);
|
980
|
-
let res = "";
|
981
|
-
for (let i = 0; i < bytes.length - 1; i += 2) {
|
982
|
-
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
983
|
-
}
|
984
|
-
return res;
|
985
|
-
}
|
986
|
-
Buffer2.prototype.slice = function slice(start, end) {
|
987
|
-
const len = this.length;
|
988
|
-
start = ~~start;
|
989
|
-
end = end === void 0 ? len : ~~end;
|
990
|
-
if (start < 0) {
|
991
|
-
start += len;
|
992
|
-
if (start < 0) start = 0;
|
993
|
-
} else if (start > len) {
|
994
|
-
start = len;
|
995
|
-
}
|
996
|
-
if (end < 0) {
|
997
|
-
end += len;
|
998
|
-
if (end < 0) end = 0;
|
999
|
-
} else if (end > len) {
|
1000
|
-
end = len;
|
1001
|
-
}
|
1002
|
-
if (end < start) end = start;
|
1003
|
-
const newBuf = this.subarray(start, end);
|
1004
|
-
Object.setPrototypeOf(newBuf, Buffer2.prototype);
|
1005
|
-
return newBuf;
|
1006
|
-
};
|
1007
|
-
function checkOffset(offset, ext, length) {
|
1008
|
-
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
1009
|
-
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
1010
|
-
}
|
1011
|
-
Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength3, noAssert) {
|
1012
|
-
offset = offset >>> 0;
|
1013
|
-
byteLength3 = byteLength3 >>> 0;
|
1014
|
-
if (!noAssert) checkOffset(offset, byteLength3, this.length);
|
1015
|
-
let val = this[offset];
|
1016
|
-
let mul = 1;
|
1017
|
-
let i = 0;
|
1018
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
1019
|
-
val += this[offset + i] * mul;
|
1020
|
-
}
|
1021
|
-
return val;
|
1022
|
-
};
|
1023
|
-
Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength3, noAssert) {
|
1024
|
-
offset = offset >>> 0;
|
1025
|
-
byteLength3 = byteLength3 >>> 0;
|
1026
|
-
if (!noAssert) {
|
1027
|
-
checkOffset(offset, byteLength3, this.length);
|
1028
|
-
}
|
1029
|
-
let val = this[offset + --byteLength3];
|
1030
|
-
let mul = 1;
|
1031
|
-
while (byteLength3 > 0 && (mul *= 256)) {
|
1032
|
-
val += this[offset + --byteLength3] * mul;
|
1033
|
-
}
|
1034
|
-
return val;
|
1035
|
-
};
|
1036
|
-
Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
1037
|
-
offset = offset >>> 0;
|
1038
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
1039
|
-
return this[offset];
|
1040
|
-
};
|
1041
|
-
Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
1042
|
-
offset = offset >>> 0;
|
1043
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
1044
|
-
return this[offset] | this[offset + 1] << 8;
|
1045
|
-
};
|
1046
|
-
Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
1047
|
-
offset = offset >>> 0;
|
1048
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
1049
|
-
return this[offset] << 8 | this[offset + 1];
|
1050
|
-
};
|
1051
|
-
Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
1052
|
-
offset = offset >>> 0;
|
1053
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
1054
|
-
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
1055
|
-
};
|
1056
|
-
Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
1057
|
-
offset = offset >>> 0;
|
1058
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
1059
|
-
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
1060
|
-
};
|
1061
|
-
Buffer2.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
1062
|
-
offset = offset >>> 0;
|
1063
|
-
validateNumber(offset, "offset");
|
1064
|
-
const first = this[offset];
|
1065
|
-
const last = this[offset + 7];
|
1066
|
-
if (first === void 0 || last === void 0) {
|
1067
|
-
boundsError(offset, this.length - 8);
|
1068
|
-
}
|
1069
|
-
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
|
1070
|
-
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
1071
|
-
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
1072
|
-
});
|
1073
|
-
Buffer2.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
1074
|
-
offset = offset >>> 0;
|
1075
|
-
validateNumber(offset, "offset");
|
1076
|
-
const first = this[offset];
|
1077
|
-
const last = this[offset + 7];
|
1078
|
-
if (first === void 0 || last === void 0) {
|
1079
|
-
boundsError(offset, this.length - 8);
|
1080
|
-
}
|
1081
|
-
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
1082
|
-
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
1083
|
-
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
1084
|
-
});
|
1085
|
-
Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength3, noAssert) {
|
1086
|
-
offset = offset >>> 0;
|
1087
|
-
byteLength3 = byteLength3 >>> 0;
|
1088
|
-
if (!noAssert) checkOffset(offset, byteLength3, this.length);
|
1089
|
-
let val = this[offset];
|
1090
|
-
let mul = 1;
|
1091
|
-
let i = 0;
|
1092
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
1093
|
-
val += this[offset + i] * mul;
|
1094
|
-
}
|
1095
|
-
mul *= 128;
|
1096
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
|
1097
|
-
return val;
|
1098
|
-
};
|
1099
|
-
Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength3, noAssert) {
|
1100
|
-
offset = offset >>> 0;
|
1101
|
-
byteLength3 = byteLength3 >>> 0;
|
1102
|
-
if (!noAssert) checkOffset(offset, byteLength3, this.length);
|
1103
|
-
let i = byteLength3;
|
1104
|
-
let mul = 1;
|
1105
|
-
let val = this[offset + --i];
|
1106
|
-
while (i > 0 && (mul *= 256)) {
|
1107
|
-
val += this[offset + --i] * mul;
|
1108
|
-
}
|
1109
|
-
mul *= 128;
|
1110
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength3);
|
1111
|
-
return val;
|
1112
|
-
};
|
1113
|
-
Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
|
1114
|
-
offset = offset >>> 0;
|
1115
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
1116
|
-
if (!(this[offset] & 128)) return this[offset];
|
1117
|
-
return (255 - this[offset] + 1) * -1;
|
1118
|
-
};
|
1119
|
-
Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
1120
|
-
offset = offset >>> 0;
|
1121
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
1122
|
-
const val = this[offset] | this[offset + 1] << 8;
|
1123
|
-
return val & 32768 ? val | 4294901760 : val;
|
1124
|
-
};
|
1125
|
-
Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
1126
|
-
offset = offset >>> 0;
|
1127
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
1128
|
-
const val = this[offset + 1] | this[offset] << 8;
|
1129
|
-
return val & 32768 ? val | 4294901760 : val;
|
1130
|
-
};
|
1131
|
-
Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
1132
|
-
offset = offset >>> 0;
|
1133
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
1134
|
-
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
1135
|
-
};
|
1136
|
-
Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
1137
|
-
offset = offset >>> 0;
|
1138
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
1139
|
-
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
1140
|
-
};
|
1141
|
-
Buffer2.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
1142
|
-
offset = offset >>> 0;
|
1143
|
-
validateNumber(offset, "offset");
|
1144
|
-
const first = this[offset];
|
1145
|
-
const last = this[offset + 7];
|
1146
|
-
if (first === void 0 || last === void 0) {
|
1147
|
-
boundsError(offset, this.length - 8);
|
1148
|
-
}
|
1149
|
-
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
1150
|
-
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
1151
|
-
});
|
1152
|
-
Buffer2.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
1153
|
-
offset = offset >>> 0;
|
1154
|
-
validateNumber(offset, "offset");
|
1155
|
-
const first = this[offset];
|
1156
|
-
const last = this[offset + 7];
|
1157
|
-
if (first === void 0 || last === void 0) {
|
1158
|
-
boundsError(offset, this.length - 8);
|
1159
|
-
}
|
1160
|
-
const val = (first << 24) + // Overflow
|
1161
|
-
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
1162
|
-
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
1163
|
-
});
|
1164
|
-
Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
1165
|
-
offset = offset >>> 0;
|
1166
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
1167
|
-
return ieee754$1.read(this, offset, true, 23, 4);
|
1168
|
-
};
|
1169
|
-
Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
1170
|
-
offset = offset >>> 0;
|
1171
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
1172
|
-
return ieee754$1.read(this, offset, false, 23, 4);
|
1173
|
-
};
|
1174
|
-
Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
1175
|
-
offset = offset >>> 0;
|
1176
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
1177
|
-
return ieee754$1.read(this, offset, true, 52, 8);
|
1178
|
-
};
|
1179
|
-
Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
1180
|
-
offset = offset >>> 0;
|
1181
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
1182
|
-
return ieee754$1.read(this, offset, false, 52, 8);
|
1183
|
-
};
|
1184
|
-
function checkInt(buf, value, offset, ext, max, min) {
|
1185
|
-
if (!Buffer2.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
1186
|
-
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
1187
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
1188
|
-
}
|
1189
|
-
Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength3, noAssert) {
|
1190
|
-
value = +value;
|
1191
|
-
offset = offset >>> 0;
|
1192
|
-
byteLength3 = byteLength3 >>> 0;
|
1193
|
-
if (!noAssert) {
|
1194
|
-
const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
|
1195
|
-
checkInt(this, value, offset, byteLength3, maxBytes, 0);
|
1196
|
-
}
|
1197
|
-
let mul = 1;
|
1198
|
-
let i = 0;
|
1199
|
-
this[offset] = value & 255;
|
1200
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
1201
|
-
this[offset + i] = value / mul & 255;
|
1202
|
-
}
|
1203
|
-
return offset + byteLength3;
|
1204
|
-
};
|
1205
|
-
Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength3, noAssert) {
|
1206
|
-
value = +value;
|
1207
|
-
offset = offset >>> 0;
|
1208
|
-
byteLength3 = byteLength3 >>> 0;
|
1209
|
-
if (!noAssert) {
|
1210
|
-
const maxBytes = Math.pow(2, 8 * byteLength3) - 1;
|
1211
|
-
checkInt(this, value, offset, byteLength3, maxBytes, 0);
|
1212
|
-
}
|
1213
|
-
let i = byteLength3 - 1;
|
1214
|
-
let mul = 1;
|
1215
|
-
this[offset + i] = value & 255;
|
1216
|
-
while (--i >= 0 && (mul *= 256)) {
|
1217
|
-
this[offset + i] = value / mul & 255;
|
1218
|
-
}
|
1219
|
-
return offset + byteLength3;
|
1220
|
-
};
|
1221
|
-
Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
1222
|
-
value = +value;
|
1223
|
-
offset = offset >>> 0;
|
1224
|
-
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
1225
|
-
this[offset] = value & 255;
|
1226
|
-
return offset + 1;
|
1227
|
-
};
|
1228
|
-
Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
1229
|
-
value = +value;
|
1230
|
-
offset = offset >>> 0;
|
1231
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
1232
|
-
this[offset] = value & 255;
|
1233
|
-
this[offset + 1] = value >>> 8;
|
1234
|
-
return offset + 2;
|
1235
|
-
};
|
1236
|
-
Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
1237
|
-
value = +value;
|
1238
|
-
offset = offset >>> 0;
|
1239
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
1240
|
-
this[offset] = value >>> 8;
|
1241
|
-
this[offset + 1] = value & 255;
|
1242
|
-
return offset + 2;
|
1243
|
-
};
|
1244
|
-
Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
1245
|
-
value = +value;
|
1246
|
-
offset = offset >>> 0;
|
1247
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
1248
|
-
this[offset + 3] = value >>> 24;
|
1249
|
-
this[offset + 2] = value >>> 16;
|
1250
|
-
this[offset + 1] = value >>> 8;
|
1251
|
-
this[offset] = value & 255;
|
1252
|
-
return offset + 4;
|
1253
|
-
};
|
1254
|
-
Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
1255
|
-
value = +value;
|
1256
|
-
offset = offset >>> 0;
|
1257
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
1258
|
-
this[offset] = value >>> 24;
|
1259
|
-
this[offset + 1] = value >>> 16;
|
1260
|
-
this[offset + 2] = value >>> 8;
|
1261
|
-
this[offset + 3] = value & 255;
|
1262
|
-
return offset + 4;
|
1263
|
-
};
|
1264
|
-
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
1265
|
-
checkIntBI(value, min, max, buf, offset, 7);
|
1266
|
-
let lo = Number(value & BigInt(4294967295));
|
1267
|
-
buf[offset++] = lo;
|
1268
|
-
lo = lo >> 8;
|
1269
|
-
buf[offset++] = lo;
|
1270
|
-
lo = lo >> 8;
|
1271
|
-
buf[offset++] = lo;
|
1272
|
-
lo = lo >> 8;
|
1273
|
-
buf[offset++] = lo;
|
1274
|
-
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
1275
|
-
buf[offset++] = hi;
|
1276
|
-
hi = hi >> 8;
|
1277
|
-
buf[offset++] = hi;
|
1278
|
-
hi = hi >> 8;
|
1279
|
-
buf[offset++] = hi;
|
1280
|
-
hi = hi >> 8;
|
1281
|
-
buf[offset++] = hi;
|
1282
|
-
return offset;
|
1283
|
-
}
|
1284
|
-
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
1285
|
-
checkIntBI(value, min, max, buf, offset, 7);
|
1286
|
-
let lo = Number(value & BigInt(4294967295));
|
1287
|
-
buf[offset + 7] = lo;
|
1288
|
-
lo = lo >> 8;
|
1289
|
-
buf[offset + 6] = lo;
|
1290
|
-
lo = lo >> 8;
|
1291
|
-
buf[offset + 5] = lo;
|
1292
|
-
lo = lo >> 8;
|
1293
|
-
buf[offset + 4] = lo;
|
1294
|
-
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
1295
|
-
buf[offset + 3] = hi;
|
1296
|
-
hi = hi >> 8;
|
1297
|
-
buf[offset + 2] = hi;
|
1298
|
-
hi = hi >> 8;
|
1299
|
-
buf[offset + 1] = hi;
|
1300
|
-
hi = hi >> 8;
|
1301
|
-
buf[offset] = hi;
|
1302
|
-
return offset + 8;
|
1303
|
-
}
|
1304
|
-
Buffer2.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
1305
|
-
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
1306
|
-
});
|
1307
|
-
Buffer2.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
1308
|
-
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
1309
|
-
});
|
1310
|
-
Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength3, noAssert) {
|
1311
|
-
value = +value;
|
1312
|
-
offset = offset >>> 0;
|
1313
|
-
if (!noAssert) {
|
1314
|
-
const limit = Math.pow(2, 8 * byteLength3 - 1);
|
1315
|
-
checkInt(this, value, offset, byteLength3, limit - 1, -limit);
|
1316
|
-
}
|
1317
|
-
let i = 0;
|
1318
|
-
let mul = 1;
|
1319
|
-
let sub = 0;
|
1320
|
-
this[offset] = value & 255;
|
1321
|
-
while (++i < byteLength3 && (mul *= 256)) {
|
1322
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
1323
|
-
sub = 1;
|
1324
|
-
}
|
1325
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
1326
|
-
}
|
1327
|
-
return offset + byteLength3;
|
1328
|
-
};
|
1329
|
-
Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength3, noAssert) {
|
1330
|
-
value = +value;
|
1331
|
-
offset = offset >>> 0;
|
1332
|
-
if (!noAssert) {
|
1333
|
-
const limit = Math.pow(2, 8 * byteLength3 - 1);
|
1334
|
-
checkInt(this, value, offset, byteLength3, limit - 1, -limit);
|
1335
|
-
}
|
1336
|
-
let i = byteLength3 - 1;
|
1337
|
-
let mul = 1;
|
1338
|
-
let sub = 0;
|
1339
|
-
this[offset + i] = value & 255;
|
1340
|
-
while (--i >= 0 && (mul *= 256)) {
|
1341
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
1342
|
-
sub = 1;
|
1343
|
-
}
|
1344
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
1345
|
-
}
|
1346
|
-
return offset + byteLength3;
|
1347
|
-
};
|
1348
|
-
Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
1349
|
-
value = +value;
|
1350
|
-
offset = offset >>> 0;
|
1351
|
-
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
1352
|
-
if (value < 0) value = 255 + value + 1;
|
1353
|
-
this[offset] = value & 255;
|
1354
|
-
return offset + 1;
|
1355
|
-
};
|
1356
|
-
Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
1357
|
-
value = +value;
|
1358
|
-
offset = offset >>> 0;
|
1359
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
1360
|
-
this[offset] = value & 255;
|
1361
|
-
this[offset + 1] = value >>> 8;
|
1362
|
-
return offset + 2;
|
1363
|
-
};
|
1364
|
-
Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
1365
|
-
value = +value;
|
1366
|
-
offset = offset >>> 0;
|
1367
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
1368
|
-
this[offset] = value >>> 8;
|
1369
|
-
this[offset + 1] = value & 255;
|
1370
|
-
return offset + 2;
|
1371
|
-
};
|
1372
|
-
Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
1373
|
-
value = +value;
|
1374
|
-
offset = offset >>> 0;
|
1375
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
1376
|
-
this[offset] = value & 255;
|
1377
|
-
this[offset + 1] = value >>> 8;
|
1378
|
-
this[offset + 2] = value >>> 16;
|
1379
|
-
this[offset + 3] = value >>> 24;
|
1380
|
-
return offset + 4;
|
1381
|
-
};
|
1382
|
-
Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
1383
|
-
value = +value;
|
1384
|
-
offset = offset >>> 0;
|
1385
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
1386
|
-
if (value < 0) value = 4294967295 + value + 1;
|
1387
|
-
this[offset] = value >>> 24;
|
1388
|
-
this[offset + 1] = value >>> 16;
|
1389
|
-
this[offset + 2] = value >>> 8;
|
1390
|
-
this[offset + 3] = value & 255;
|
1391
|
-
return offset + 4;
|
1392
|
-
};
|
1393
|
-
Buffer2.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
1394
|
-
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
1395
|
-
});
|
1396
|
-
Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
1397
|
-
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
1398
|
-
});
|
1399
|
-
function checkIEEE754(buf, value, offset, ext, max, min) {
|
1400
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
1401
|
-
if (offset < 0) throw new RangeError("Index out of range");
|
1402
|
-
}
|
1403
|
-
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
1404
|
-
value = +value;
|
1405
|
-
offset = offset >>> 0;
|
1406
|
-
if (!noAssert) {
|
1407
|
-
checkIEEE754(buf, value, offset, 4);
|
1408
|
-
}
|
1409
|
-
ieee754$1.write(buf, value, offset, littleEndian, 23, 4);
|
1410
|
-
return offset + 4;
|
1411
|
-
}
|
1412
|
-
Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
1413
|
-
return writeFloat(this, value, offset, true, noAssert);
|
1414
|
-
};
|
1415
|
-
Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
1416
|
-
return writeFloat(this, value, offset, false, noAssert);
|
1417
|
-
};
|
1418
|
-
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
1419
|
-
value = +value;
|
1420
|
-
offset = offset >>> 0;
|
1421
|
-
if (!noAssert) {
|
1422
|
-
checkIEEE754(buf, value, offset, 8);
|
1423
|
-
}
|
1424
|
-
ieee754$1.write(buf, value, offset, littleEndian, 52, 8);
|
1425
|
-
return offset + 8;
|
1426
|
-
}
|
1427
|
-
Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
1428
|
-
return writeDouble(this, value, offset, true, noAssert);
|
1429
|
-
};
|
1430
|
-
Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
1431
|
-
return writeDouble(this, value, offset, false, noAssert);
|
1432
|
-
};
|
1433
|
-
Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
|
1434
|
-
if (!Buffer2.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
1435
|
-
if (!start) start = 0;
|
1436
|
-
if (!end && end !== 0) end = this.length;
|
1437
|
-
if (targetStart >= target.length) targetStart = target.length;
|
1438
|
-
if (!targetStart) targetStart = 0;
|
1439
|
-
if (end > 0 && end < start) end = start;
|
1440
|
-
if (end === start) return 0;
|
1441
|
-
if (target.length === 0 || this.length === 0) return 0;
|
1442
|
-
if (targetStart < 0) {
|
1443
|
-
throw new RangeError("targetStart out of bounds");
|
1444
|
-
}
|
1445
|
-
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
1446
|
-
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
1447
|
-
if (end > this.length) end = this.length;
|
1448
|
-
if (target.length - targetStart < end - start) {
|
1449
|
-
end = target.length - targetStart + start;
|
1450
|
-
}
|
1451
|
-
const len = end - start;
|
1452
|
-
if (this === target && typeof GlobalUint8Array.prototype.copyWithin === "function") {
|
1453
|
-
this.copyWithin(targetStart, start, end);
|
1454
|
-
} else {
|
1455
|
-
GlobalUint8Array.prototype.set.call(
|
1456
|
-
target,
|
1457
|
-
this.subarray(start, end),
|
1458
|
-
targetStart
|
1459
|
-
);
|
1460
|
-
}
|
1461
|
-
return len;
|
1462
|
-
};
|
1463
|
-
Buffer2.prototype.fill = function fill(val, start, end, encoding) {
|
1464
|
-
if (typeof val === "string") {
|
1465
|
-
if (typeof start === "string") {
|
1466
|
-
encoding = start;
|
1467
|
-
start = 0;
|
1468
|
-
end = this.length;
|
1469
|
-
} else if (typeof end === "string") {
|
1470
|
-
encoding = end;
|
1471
|
-
end = this.length;
|
1472
|
-
}
|
1473
|
-
if (encoding !== void 0 && typeof encoding !== "string") {
|
1474
|
-
throw new TypeError("encoding must be a string");
|
1475
|
-
}
|
1476
|
-
if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
|
1477
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
1478
|
-
}
|
1479
|
-
if (val.length === 1) {
|
1480
|
-
const code2 = val.charCodeAt(0);
|
1481
|
-
if (encoding === "utf8" && code2 < 128 || encoding === "latin1") {
|
1482
|
-
val = code2;
|
1483
|
-
}
|
1484
|
-
}
|
1485
|
-
} else if (typeof val === "number") {
|
1486
|
-
val = val & 255;
|
1487
|
-
} else if (typeof val === "boolean") {
|
1488
|
-
val = Number(val);
|
1489
|
-
}
|
1490
|
-
if (start < 0 || this.length < start || this.length < end) {
|
1491
|
-
throw new RangeError("Out of range index");
|
1492
|
-
}
|
1493
|
-
if (end <= start) {
|
1494
|
-
return this;
|
1495
|
-
}
|
1496
|
-
start = start >>> 0;
|
1497
|
-
end = end === void 0 ? this.length : end >>> 0;
|
1498
|
-
if (!val) val = 0;
|
1499
|
-
let i;
|
1500
|
-
if (typeof val === "number") {
|
1501
|
-
for (i = start; i < end; ++i) {
|
1502
|
-
this[i] = val;
|
1503
|
-
}
|
1504
|
-
} else {
|
1505
|
-
const bytes = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding);
|
1506
|
-
const len = bytes.length;
|
1507
|
-
if (len === 0) {
|
1508
|
-
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
1509
|
-
}
|
1510
|
-
for (i = 0; i < end - start; ++i) {
|
1511
|
-
this[i + start] = bytes[i % len];
|
1512
|
-
}
|
1513
|
-
}
|
1514
|
-
return this;
|
1515
|
-
};
|
1516
|
-
const errors = {};
|
1517
|
-
function E(sym, getMessage, Base) {
|
1518
|
-
errors[sym] = class NodeError extends Base {
|
1519
|
-
constructor() {
|
1520
|
-
super();
|
1521
|
-
Object.defineProperty(this, "message", {
|
1522
|
-
value: getMessage.apply(this, arguments),
|
1523
|
-
writable: true,
|
1524
|
-
configurable: true
|
1525
|
-
});
|
1526
|
-
this.name = `${this.name} [${sym}]`;
|
1527
|
-
this.stack;
|
1528
|
-
delete this.name;
|
1529
|
-
}
|
1530
|
-
get code() {
|
1531
|
-
return sym;
|
1532
|
-
}
|
1533
|
-
set code(value) {
|
1534
|
-
Object.defineProperty(this, "code", {
|
1535
|
-
configurable: true,
|
1536
|
-
enumerable: true,
|
1537
|
-
value,
|
1538
|
-
writable: true
|
1539
|
-
});
|
1540
|
-
}
|
1541
|
-
toString() {
|
1542
|
-
return `${this.name} [${sym}]: ${this.message}`;
|
1543
|
-
}
|
1544
|
-
};
|
1545
|
-
}
|
1546
|
-
E(
|
1547
|
-
"ERR_BUFFER_OUT_OF_BOUNDS",
|
1548
|
-
function(name) {
|
1549
|
-
if (name) {
|
1550
|
-
return `${name} is outside of buffer bounds`;
|
1551
|
-
}
|
1552
|
-
return "Attempt to access memory outside buffer bounds";
|
1553
|
-
},
|
1554
|
-
RangeError
|
1555
|
-
);
|
1556
|
-
E(
|
1557
|
-
"ERR_INVALID_ARG_TYPE",
|
1558
|
-
function(name, actual) {
|
1559
|
-
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
1560
|
-
},
|
1561
|
-
TypeError
|
1562
|
-
);
|
1563
|
-
E(
|
1564
|
-
"ERR_OUT_OF_RANGE",
|
1565
|
-
function(str, range, input) {
|
1566
|
-
let msg = `The value of "${str}" is out of range.`;
|
1567
|
-
let received = input;
|
1568
|
-
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
1569
|
-
received = addNumericalSeparator(String(input));
|
1570
|
-
} else if (typeof input === "bigint") {
|
1571
|
-
received = String(input);
|
1572
|
-
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
1573
|
-
received = addNumericalSeparator(received);
|
1574
|
-
}
|
1575
|
-
received += "n";
|
1576
|
-
}
|
1577
|
-
msg += ` It must be ${range}. Received ${received}`;
|
1578
|
-
return msg;
|
1579
|
-
},
|
1580
|
-
RangeError
|
1581
|
-
);
|
1582
|
-
function addNumericalSeparator(val) {
|
1583
|
-
let res = "";
|
1584
|
-
let i = val.length;
|
1585
|
-
const start = val[0] === "-" ? 1 : 0;
|
1586
|
-
for (; i >= start + 4; i -= 3) {
|
1587
|
-
res = `_${val.slice(i - 3, i)}${res}`;
|
1588
|
-
}
|
1589
|
-
return `${val.slice(0, i)}${res}`;
|
1590
|
-
}
|
1591
|
-
function checkBounds(buf, offset, byteLength3) {
|
1592
|
-
validateNumber(offset, "offset");
|
1593
|
-
if (buf[offset] === void 0 || buf[offset + byteLength3] === void 0) {
|
1594
|
-
boundsError(offset, buf.length - (byteLength3 + 1));
|
1595
|
-
}
|
1596
|
-
}
|
1597
|
-
function checkIntBI(value, min, max, buf, offset, byteLength3) {
|
1598
|
-
if (value > max || value < min) {
|
1599
|
-
const n = typeof min === "bigint" ? "n" : "";
|
1600
|
-
let range;
|
1601
|
-
{
|
1602
|
-
if (min === 0 || min === BigInt(0)) {
|
1603
|
-
range = `>= 0${n} and < 2${n} ** ${(byteLength3 + 1) * 8}${n}`;
|
1604
|
-
} else {
|
1605
|
-
range = `>= -(2${n} ** ${(byteLength3 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength3 + 1) * 8 - 1}${n}`;
|
1606
|
-
}
|
1607
|
-
}
|
1608
|
-
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
1609
|
-
}
|
1610
|
-
checkBounds(buf, offset, byteLength3);
|
1611
|
-
}
|
1612
|
-
function validateNumber(value, name) {
|
1613
|
-
if (typeof value !== "number") {
|
1614
|
-
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
1615
|
-
}
|
1616
|
-
}
|
1617
|
-
function boundsError(value, length, type) {
|
1618
|
-
if (Math.floor(value) !== value) {
|
1619
|
-
validateNumber(value, type);
|
1620
|
-
throw new errors.ERR_OUT_OF_RANGE("offset", "an integer", value);
|
1621
|
-
}
|
1622
|
-
if (length < 0) {
|
1623
|
-
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
1624
|
-
}
|
1625
|
-
throw new errors.ERR_OUT_OF_RANGE(
|
1626
|
-
"offset",
|
1627
|
-
`>= ${0} and <= ${length}`,
|
1628
|
-
value
|
1629
|
-
);
|
1630
|
-
}
|
1631
|
-
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
1632
|
-
function base64clean(str) {
|
1633
|
-
str = str.split("=")[0];
|
1634
|
-
str = str.trim().replace(INVALID_BASE64_RE, "");
|
1635
|
-
if (str.length < 2) return "";
|
1636
|
-
while (str.length % 4 !== 0) {
|
1637
|
-
str = str + "=";
|
1638
|
-
}
|
1639
|
-
return str;
|
1640
|
-
}
|
1641
|
-
function utf8ToBytes(string, units) {
|
1642
|
-
units = units || Infinity;
|
1643
|
-
let codePoint;
|
1644
|
-
const length = string.length;
|
1645
|
-
let leadSurrogate = null;
|
1646
|
-
const bytes = [];
|
1647
|
-
for (let i = 0; i < length; ++i) {
|
1648
|
-
codePoint = string.charCodeAt(i);
|
1649
|
-
if (codePoint > 55295 && codePoint < 57344) {
|
1650
|
-
if (!leadSurrogate) {
|
1651
|
-
if (codePoint > 56319) {
|
1652
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
1653
|
-
continue;
|
1654
|
-
} else if (i + 1 === length) {
|
1655
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
1656
|
-
continue;
|
1657
|
-
}
|
1658
|
-
leadSurrogate = codePoint;
|
1659
|
-
continue;
|
1660
|
-
}
|
1661
|
-
if (codePoint < 56320) {
|
1662
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
1663
|
-
leadSurrogate = codePoint;
|
1664
|
-
continue;
|
1665
|
-
}
|
1666
|
-
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
1667
|
-
} else if (leadSurrogate) {
|
1668
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
1669
|
-
}
|
1670
|
-
leadSurrogate = null;
|
1671
|
-
if (codePoint < 128) {
|
1672
|
-
if ((units -= 1) < 0) break;
|
1673
|
-
bytes.push(codePoint);
|
1674
|
-
} else if (codePoint < 2048) {
|
1675
|
-
if ((units -= 2) < 0) break;
|
1676
|
-
bytes.push(
|
1677
|
-
codePoint >> 6 | 192,
|
1678
|
-
codePoint & 63 | 128
|
1679
|
-
);
|
1680
|
-
} else if (codePoint < 65536) {
|
1681
|
-
if ((units -= 3) < 0) break;
|
1682
|
-
bytes.push(
|
1683
|
-
codePoint >> 12 | 224,
|
1684
|
-
codePoint >> 6 & 63 | 128,
|
1685
|
-
codePoint & 63 | 128
|
1686
|
-
);
|
1687
|
-
} else if (codePoint < 1114112) {
|
1688
|
-
if ((units -= 4) < 0) break;
|
1689
|
-
bytes.push(
|
1690
|
-
codePoint >> 18 | 240,
|
1691
|
-
codePoint >> 12 & 63 | 128,
|
1692
|
-
codePoint >> 6 & 63 | 128,
|
1693
|
-
codePoint & 63 | 128
|
1694
|
-
);
|
1695
|
-
} else {
|
1696
|
-
throw new Error("Invalid code point");
|
1697
|
-
}
|
1698
|
-
}
|
1699
|
-
return bytes;
|
1700
|
-
}
|
1701
|
-
function asciiToBytes(str) {
|
1702
|
-
const byteArray = [];
|
1703
|
-
for (let i = 0; i < str.length; ++i) {
|
1704
|
-
byteArray.push(str.charCodeAt(i) & 255);
|
1705
|
-
}
|
1706
|
-
return byteArray;
|
1707
|
-
}
|
1708
|
-
function utf16leToBytes(str, units) {
|
1709
|
-
let c, hi, lo;
|
1710
|
-
const byteArray = [];
|
1711
|
-
for (let i = 0; i < str.length; ++i) {
|
1712
|
-
if ((units -= 2) < 0) break;
|
1713
|
-
c = str.charCodeAt(i);
|
1714
|
-
hi = c >> 8;
|
1715
|
-
lo = c % 256;
|
1716
|
-
byteArray.push(lo);
|
1717
|
-
byteArray.push(hi);
|
1718
|
-
}
|
1719
|
-
return byteArray;
|
1720
|
-
}
|
1721
|
-
function base64ToBytes(str) {
|
1722
|
-
return base64.toByteArray(base64clean(str));
|
1723
|
-
}
|
1724
|
-
function blitBuffer(src, dst, offset, length) {
|
1725
|
-
let i;
|
1726
|
-
for (i = 0; i < length; ++i) {
|
1727
|
-
if (i + offset >= dst.length || i >= src.length) break;
|
1728
|
-
dst[i + offset] = src[i];
|
1729
|
-
}
|
1730
|
-
return i;
|
1731
|
-
}
|
1732
|
-
function isInstance(obj, type) {
|
1733
|
-
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
1734
|
-
}
|
1735
|
-
function numberIsNaN(obj) {
|
1736
|
-
return obj !== obj;
|
1737
|
-
}
|
1738
|
-
const hexSliceLookupTable = function() {
|
1739
|
-
const alphabet = "0123456789abcdef";
|
1740
|
-
const table = new Array(256);
|
1741
|
-
for (let i = 0; i < 16; ++i) {
|
1742
|
-
const i16 = i * 16;
|
1743
|
-
for (let j = 0; j < 16; ++j) {
|
1744
|
-
table[i16 + j] = alphabet[i] + alphabet[j];
|
1745
|
-
}
|
1746
|
-
}
|
1747
|
-
return table;
|
1748
|
-
}();
|
1749
|
-
function defineBigIntMethod(fn) {
|
1750
|
-
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
1751
|
-
}
|
1752
|
-
function BufferBigIntNotDefined() {
|
1753
|
-
throw new Error("BigInt not supported");
|
1754
|
-
}
|
1755
|
-
})(buffer);
|
1756
|
-
const Buffer = buffer.Buffer;
|
1757
|
-
export {
|
1758
|
-
Buffer as B
|
1759
|
-
};
|