INNER CODE UNIT · JavaScript
parts
AscensionGameDev/Intersect-Engine · Intersect.Server/wwwroot/js/assets.js:895
const parts = target.split('/').filter(p => p.length > 0);
let current = root;
for (let depth = 0; current.children && depth < parts.length - 1; ++depth) {
/** @type {LocalStorageBrowseNode | null} */
let next = current.children.find(c => c.Name === parts[depth]) ?? null;
if (next === null && createMissing) {
console.debug(`Did not find '${parts[depth]}' in ${current.id}'s children ${current.children.map(c => c.Name).join(', ')}`);
const path = parts.filter((_, i) => i <= depth).join('/');
next = {
id: encodeURIComponent(path),
Name: parts[depth],
Path: path,
Type: 'Directory',
children: [],
};
current.children.push(next);
}