WXL
3 天以前 4d9da000fbe74d344e0e4580b138e79d4ad98ede
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toAscii = exports.fromAscii = exports.fromBigInt = exports.toBigInt = exports.toHex = exports.fromHex = exports.toBase64 = exports.fromBase64 = exports.toUtf8 = exports.fromUtf8 = void 0;
const buffer_1 = require("buffer");
function fromUtf8(str) {
    return Uint8Array.from(buffer_1.Buffer.from(str, "utf-8"));
}
exports.fromUtf8 = fromUtf8;
function toUtf8(bytes) {
    return buffer_1.Buffer.from(bytes).toString("utf-8");
}
exports.toUtf8 = toUtf8;
function fromBase64(str) {
    return Uint8Array.from(buffer_1.Buffer.from(str, "base64"));
}
exports.fromBase64 = fromBase64;
function toBase64(bytes) {
    return buffer_1.Buffer.from(bytes).toString("base64");
}
exports.toBase64 = toBase64;
function fromHex(str) {
    return str.startsWith("0x")
        ? Uint8Array.from(buffer_1.Buffer.from(str.slice(2), "hex"))
        : Uint8Array.from(buffer_1.Buffer.from(str, "hex"));
}
exports.fromHex = fromHex;
function toHex(bytes) {
    return buffer_1.Buffer.from(bytes).toString("hex");
}
exports.toHex = toHex;
function toBigInt(bytes) {
    return BigInt(`0x${toHex(bytes)}`);
}
exports.toBigInt = toBigInt;
function fromBigInt(i) {
    return fromHex(i.toString(16));
}
exports.fromBigInt = fromBigInt;
function fromAscii(str) {
    return Uint8Array.from(buffer_1.Buffer.from(str, "ascii"));
}
exports.fromAscii = fromAscii;
function toAscii(bytes) {
    return buffer_1.Buffer.from(bytes).toString("ascii");
}
exports.toAscii = toAscii;
//# sourceMappingURL=encoding.js.map