clean up uuid

This commit is contained in:
Skyler Lehmkuhl 2024-12-29 00:02:14 -05:00
parent 57f1a05cd6
commit a975195f6a
1 changed files with 2 additions and 7 deletions

View File

@ -3263,20 +3263,15 @@ async function importFile() {
function assignUUIDs(obj, existing) {
const uuidCache = {}; // Cache to store UUIDs for existing values
// Helper function to generate a UUID (or use a library like uuid for this)
function generateUUID() {
return 'uuid' + Math.floor(Math.random() * 10000);
}
function deepAssign(obj) {
for (const [key, value] of Object.entries(obj)) {
if (typeof value === 'object' && value !== null) {
// Recurse for nested objects
deepAssign(value);
} else if (value in existing) {
} else if (value in existing && key != "name") {
// If the value is in the "existing" list, assign a UUID
if (!uuidCache[value]) {
uuidCache[value] = generateUUID(); // Store the generated UUID for the value
uuidCache[value] = uuidv4(); // Store the generated UUID for the value
}
obj[key] = uuidCache[value]; // Assign the UUID to the object property
}