Files
NapCatQQ/.pnpm-store/v3/files/2c/7d830edd314ab5d344799e477cdcc5835e0e2b6d1b2af648ed5c3e529cb7e9020c09338d0c60823e05501d20af366076eae3275580d7cbc6a197d282c15151
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

42 lines
960 B
Plaintext

// src/utils/object.ts
import flatten from "flat";
function swapColorValues(colors) {
const swappedColors = {};
const keys = Object.keys(colors);
const length = keys.length;
for (let i = 0; i < length / 2; i++) {
const key1 = keys[i];
const key2 = keys[length - 1 - i];
swappedColors[key1] = colors[key2];
swappedColors[key2] = colors[key1];
}
if (length % 2 !== 0) {
const middleKey = keys[Math.floor(length / 2)];
swappedColors[middleKey] = colors[middleKey];
}
return swappedColors;
}
function removeDefaultKeys(obj) {
const newObj = {};
for (const key in obj) {
if (key.endsWith("-DEFAULT")) {
newObj[key.replace("-DEFAULT", "")] = obj[key];
continue;
}
newObj[key] = obj[key];
}
return newObj;
}
var flattenThemeObject = (obj) => removeDefaultKeys(
flatten(obj, {
safe: true,
delimiter: "-"
})
);
export {
swapColorValues,
removeDefaultKeys,
flattenThemeObject
};