Published
Edited
Nov 11, 2019
2 stars
Insert cell
Insert cell
Insert cell
{
let flatElements = [];
const recursiveFunc = (data, pathElements) => {
_.forEach(data, (value, key) => {
pathElements.push(key);
if (_.isObject(_.find(value, () => true))) {
recursiveFunc(value, pathElements);
} else {
flatElements.push(_.concat(pathElements, _.map(value, field => field)));
}
pathElements.splice(-1, 1);
})
}
recursiveFunc(dataMap, []);
return flatElements;
}
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