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

62 lines
1.7 KiB
JavaScript

// Metro module 6469 (f6470).
import { dropUndefinedKeys } from "./addNonEnumerableProperty_6374";
let c4165_3 = [["\n", "\\n"], ["\r", "\\r"], ["\t", "\\t"], ["\\", "\\\\"], ["|", "\\u{7c}"], [",", "\\u{2c}"]];
export function getBucketKey(a0, a1, a2, a3) {
return `${a0}${a1}${a2}${Object.entries(dropUndefinedKeys(a3)).sort((a, b) => a[0].localeCompare(b[0]))}`;
}
export function sanitizeMetricKey(a0) {
return a0.replace(/[^\w\-.]+/gi, "_");
}
export function sanitizeTags(a0) {
const r5 = {};
for (const key in a0) {
if (Object.prototype.hasOwnProperty.call(a0, key)) {
r5[key.replace(/[^\w\-./]+/gi, "")] = [...String(a0[key])].reduce((acc, a1) => acc + (function getCharOrReplacement(a0) {
for (const item of c4165_3) {
const [r26, r27] = item;
if (a0 !== r26) {
continue;
}
return r27;
}
return a0;
})(a1), "");
}
}
return r5;
}
export function sanitizeUnit(a0) {
return a0.replace(/[^\w]+/gi, "_");
}
export function serializeMetricBuckets(a0) {
let r0 = "";
for (const item of a0) {
const r50 = Object.entries(item.tags);
const r23 = r50.length > 0 ? `|#${r50.map((item) => {
const [r7, r24] = item;
return `${r7}:${r24}`;
}).join(",")}` : "";
const r62 = r0;
r0 = r62 + `${item.name}@${item.unit}:${item.metric}|${item.metricType}${r23}|T${item.timestamp}
`;
}
return r0;
}
export function simpleHash(a0) {
let length;
const r8 = 0 < a0.length;
let r1 = 0;
let r0 = 0;
let r3 = 0;
if (r8) {
do {
const r14 = (r0 << 5) - r0 + a0.charCodeAt(r1);
r0 = r14 & r14;
r1 = r1 + 1;
length = a0.length;
r3 = r0;
} while (r1 < length);
}
return r3 >>> 0;
}