Public
Edited
Feb 28
Paused
Importers
18 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
asFacets = data => {
const root = {route: [], children: new Map()};
const add = (parent, key) => {
const entry = {
key: parent.key != null ? `${parent.key}__${key}` : key,
route: [...parent.route, key],
children: new Map()
};
parent.children.set(key, entry);
return entry;
};
const propMap = rollupProps(data, {
base: root,
path: (value, key, parent) => Array.isArray(value)
? parent
: parent.children.get(key) ?? add(parent, key)
});
const entries = [...propMap];

const proxy = values => {
const _values = [...values];
const filteredEntries = new Map(
entries
.map(([path, set]) => [path.key, _values.filter(d => set.has(d))])
.filter(d => d[1].length)
);
return new Proxy({}, {
ownKeys: () => [...filteredEntries.keys()],
get: (target, name) => proxy(filteredEntries.get(name)),
});
};

const byKey = new Map([...propMap].map(d => [d[0].key, d[1]]));
return new Proxy({}, {
ownKeys: () => [...byKey.keys()],
get: (target, name) => (byKey.get(name) ?? []),
});
}
Insert cell
expandInspect_doc = runExample(()=>
expandInspect(
inlineInspect({ foo: { bar: { baz: 123 } } }),
2 // max depth
), {name: "expandInspect", title: "Expand Inspector output", visibility})
Insert cell
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