"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
|