Files
discord-decomp/_bundle/bytes.js
T
2026-11-01 12:12:55 +02:00

64 lines
1.9 KiB
JavaScript

// Metro module 8884 (f8885).
let bytes;
export function number(a0) {
if (Number.isSafeInteger(a0) && !(a0 < 0)) {
return void 0;
}
throw new Error(`positive integer expected, not ${a0}`);
}
export function bool(a0) {
if (typeof a0 !== "boolean") {
throw new Error(`boolean expected, not ${a0}`);
}
}
bytes = function bytes(a0, ...args) {
if (a0 instanceof Uint8Array || a0 != null && typeof a0 === "object" && a0.constructor.name === "Uint8Array") {
if (args.length > 0 && !args.includes(a0.length)) {
throw new Error(`Uint8Array expected of length ${args}, not of length=${a0.length}`);
}
return void 0;
}
throw new Error("Uint8Array expected");
};
export function hash(a0) {
if (typeof a0 === "function" && typeof a0.create === "function") {
const outputLen = a0.outputLen;
if (Number.isSafeInteger(outputLen) && !(outputLen < 0)) {
const blockLen = a0.blockLen;
if (Number.isSafeInteger(blockLen) && !(blockLen < 0)) {
return void 0;
}
throw new Error(`positive integer expected, not ${blockLen}`);
}
throw new Error(`positive integer expected, not ${outputLen}`);
}
throw new Error("Hash should be wrapped by utils.wrapConstructor");
}
export function exists(a0, r3 = true) {
if (a0.destroyed) {
throw new Error("Hash instance has been destroyed");
}
if (r3 && a0.finished) {
throw new Error("Hash#digest() has already been called");
}
}
export function output(a0, a1) {
bytes(a0);
const outputLen = a1.outputLen;
if (a0.length < outputLen) {
throw new Error(`digestInto() expects output buffer of length at least ${outputLen}`);
}
}
export function isBytes(a0) {
return a0 instanceof Uint8Array || a0 != null && typeof a0 === "object" && a0.constructor.name === "Uint8Array";
}
export { bytes };
export default {
number,
bool,
bytes,
hash,
exists,
output
};