Published
Edited
Aug 11, 2018
Importers
Insert cell
Insert cell
async function parse_thrift_root(thrift_file_objs) {
let results = thrift_root(),
name_map = new Map(),
includes = [];
// Parse files and create name => obj map for each
for (let i=0; i<thrift_file_objs.length; i++) {
let obj = thrift_file_objs[i];
const fcode = await obj.text;
try {
obj.thrift = eleme_parser(fcode);
obj.children = [];
name_map.set(obj.name, obj);
console.log("Mapping obj to " + obj.name);
if (obj.thrift.include == null) {
results.no_includes.children.push(obj);
} else {
includes.push(obj);
}
} catch (error) {
obj.thrift = "error";
results.errors.children.push(obj);
}
}
// Add children objs to the parents they include from
includes.forEach((obj, index) => {
const kid = obj.thrift.include;
const kids = Object.keys(kid);
console.log(kid);
console.log(kids);
kids.forEach((parent_key, pindex) => {
console.log("Searching for parent " + kid[parent_key].path);
let pobj = name_map.get(kid[parent_key].path);
pobj && pobj.children.push(obj);
});
});
return results;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more