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

74 lines
1.9 KiB
JavaScript

// Metro module 883 (f884).
import * as _slicedToArray from "./_slicedToArray";
let attributeValueToTypedAttributeValue;
const isAttributeObject = function isAttributeObject(a0) {
return (typeof a0 === "object" ? a0 != null : typeof a0 === "object") && !Array.isArray(a0) && Object.keys(a0).includes("value");
};
attributeValueToTypedAttributeValue = function attributeValueToTypedAttributeValue(a0, a1) {
const r10 = isAttributeObject(a0) ? a0 : {
value: a0,
unit: void 0
};
const { value, unit } = r10;
const r13 = (function getTypedAttributeValue(a0) {
const type = typeof a0 !== "string" ? typeof a0 !== "boolean" ? typeof a0 === "number" ? Number.isNaN(a0) ? null : Number.isInteger(a0) ? "integer" : "double" : null : "boolean" : "string";
if (type) {
return {
value: a0,
type
};
}
})(value);
const r14 = unit && typeof unit === "string" ? {
unit
} : {};
if (r13) {
return {
...r13,
...r14
};
}
L10: {
if (a1) {
if (a1 === "skip-undefined" && value === void 0) {
break L10;
}
let value2 = "";
try {
let r23 = JSON.stringify(value);
if (r23 == null) {
r23 = "";
}
value2 = r23;
} catch ($e) {}
return {
value: value2,
type: "string",
...r14
};
}
}
};
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
export { attributeValueToTypedAttributeValue };
export { isAttributeObject };
export function serializeAttributes(a0, r7 = false) {
let r3 = a0;
const r0 = {};
const r2 = Object;
if (a0 == null) {
r3 = {};
}
for (const item of r2.entries(r3)) {
const r32 = _slicedToArray(item, 2);
const r33 = r32[0];
const r36 = attributeValueToTypedAttributeValue(r32[1], r7);
if (r36) {
r0[r33] = r36;
}
}
return r0;
}