data = {
const root = {};
const map = new Map([[".", root]]);
function get(path) {
if (map.has(path)) return map.get(path);
const i = path.lastIndexOf("/");
const node = {name: path.substring(i + 1)};
const parent = get(path.substring(0, i));
if (parent.children) parent.children.push(node);
else parent.children = [node];
map.set(path, node);
return node;
}
for (let [value, path] of source.trim()
.split(/\r?\n/g)
.map(line => line.trim().split(/\s+/g))) {
if (path === "total") continue;
if (!/^\.\//.test(path)) path = `./${path}`;
get(path).value = +value;
}
return root;
}