Public
Edited
Apr 2, 2024
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
url = moduleUrl(id || "@bogo/timelib")
Insert cell
imports = fetchAllImports(url)
Insert cell
async function* fetchAllImports(url) {
const urls = new Set([url]);
const imports = [];
yield imports;
for (const url of urls) {
const urlImports = await fetchImports(url);
for (const importUrl of urlImports) {
urls.add(importUrl[0]);
imports.push([url, importUrl]);
yield imports;
}
}
}
Insert cell
Insert cell
// returns an array for each import declaration: [href, symbols]
function parseImports(text) {
const program = acorn.parse(text, {
ecmaVersion: 11,
sourceType: "module"
});
return program.body
.filter(node => node.type === "ImportDeclaration")
.map(node =>
[
new URL(node.source.value, url) + ""
, // that's the closest I could get to the imported symbol:
node.specifiers.map( spec => spec.local.name ).join(", ")
]
);
}
Insert cell
// return a string which is also valid as CSS identifier (required by KTS)
function idName( name )
{
return "notebook_" + displayName( name ).replace( /[\/@-]/ig , '_' );
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// setup KTS visualization
{
init( graphic );
visco.press("h"); // hyperlink mode
visco.press("Escape"); // hide Actions and Keys
visco.press("Escape");
return css;
}
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