Published
Edited
Apr 30, 2019
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
notebook = nb_modules.default.modules[0]
Insert cell
transform_var = notebook.variables.filter(({name}) => (name == "transform"))[0]
Insert cell
transform_imports = transform_var.inputs.map( (i) => notebook.variables.filter(({name}) => (name == i)))
Insert cell
transform_code = transform_var.value(R).toString()
Insert cell
Insert cell
Insert cell
transform = function(keep_paths, del_paths, obj) {
// Create an object copy of the element corresponding to path
const duplicate = (path,o) => R.assocPath(path, R.view(R.lensPath(path),obj) , {});
// Calculate for a path collection the corresponding copy object collection
const gather_parts = (o) => keep_paths.map(p => duplicate(p,obj));
// Merge object parts into a single ob,ect
const merge_parts = (parts) => parts.reduce((o1,o2) => R.mergeDeepLeft(o1,o2), {});
// Suppress the object corresponding to a path collection
const suppress_deleted_parts = (o) => R.reduce((r,d) => R.dissocPath(d,r),o, del_paths);
return R.pipe(gather_parts,merge_parts,suppress_deleted_parts)(obj);
}
Insert cell
Insert cell
viewof targetjsontree = treeviewer(transformed_object,["expand","showcount","readonly"])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
he = require('he@1.2.0/he.js')
Insert cell
jtv = require('https://bundle.run/json-tree-view@0.4.10')
Insert cell
Insert cell
stylesheet = html`<link rel='stylesheet'
href='https://unpkg.com/json-tree-view@0.4.10/devtools.css' />`
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