Published unlisted
Edited
Nov 16, 2020
Importers
5 stars
Insert cell
Insert cell
oldSetForEach = {
if (!window._oldSetForEach) window._oldSetForEach = Set.prototype.forEach;
return window._oldSetForEach;
}
Insert cell
override = {
if (!window._MAIN) {
Set.prototype.forEach = function newForEach() {
if (!window._MAIN)
for (const s of this) {
if (
s._module &&
s._module._scope &&
s._module._scope.has("oldSetForEach")
) {
window._MAIN = s._module;
console.log('caught MAIN');
Set.prototype.forEach = oldSetForEach;
console.log('Set.prototype.forEach restored!');
break;
}
}
oldSetForEach.apply(this, arguments);
};
console.log('Set.prototype.forEach overridden!');
}
}
Insert cell
trigger = {
override;
// since there are cells "downstream" of this generator cell,
// when it yields, it triggers runtime_compute and hence Set.prototype.forEach
while (!window._MAIN) yield false;
yield true;
}
Insert cell
MAIN = trigger ? window._MAIN : null
Insert cell
RUNTIME = MAIN._runtime
Insert cell
RUNTIME._variables
Insert cell
Array.from(RUNTIME._modules.entries())
Insert cell
{
const map = new Map();
let nullCount = 0;
for (const v of RUNTIME._variables) {
const name = v._name || `#${nullCount++}`;
map.set(name, v._inputs.map(({ _name }) => _name)); // handle imports
}
return map;
}
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