Published
Edited
Apr 29, 2021
2 stars
Insert cell
Insert cell
Insert cell
_ = require("lodash@4") // most recent per 2021-02-21
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
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
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
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
// including anonymous cells
notebookCellCount = {
await visibility();
const module = await importCurrentNotebook();
const defaultModule = module.default.modules[0];
return defaultModule.variables.length;
}
Insert cell
// merging back and forth with the (grand-)parent (@nikita-sharov/lodash-documentation-generator);
// forked again and trashed its parent
notebookVersion = {
await visibility();
const source = await fetchCurrentNotebookSource();
const regex = /\/\/ Version: (\d+)\n/;
const result = regex.exec(source);
return +result[1];
}
Insert cell
// see "Notebooks as ES modules": https://observablehq.com/@observablehq/downloading-and-embedding-notebooks
importCurrentNotebook = () => {
const path = new URL(document.baseURI).pathname;
const url = `https://api.observablehq.com${path}.js`
return import(url);
}
Insert cell
getCurrentNotebookSourceUrl = () => {
const path = new URL(document.baseURI).pathname;
return `https://api.observablehq.com${path}.js`;
}
Insert cell
// see: https://observablehq.com/@mootari/notebook-data
fetchCurrentNotebookSource = () => {
const url = getCurrentNotebookSourceUrl();
return fetch(url).then(response => response.text());
}
Insert cell
Insert cell
createHeading = (text, level) => html`<div class="markdown-body"><h${level}>${text}</h${level}></div>`
Insert cell
createSectionHeading = (text) => createHeading(text, 2)
Insert cell
createSubSectionHeading = (text) => createHeading(text, 3)
Insert cell
getLicense = () => {
const block = _.first(commentBlocks);
return block.source.map(d => d.source)
.join("\n");
}
Insert cell
import {commentBlocks, compose, composeParagraphed}
with {marked as marked}
from "@nikita-sharov/lodash-documentation-generator"
Insert cell
composeOn = async (visibility, methodName, ...tags) => {
await visibility(); // https://observablehq.com/@observablehq/awaiting-visibility
return compose(methodName, {tags});
}
Insert cell
composeParagraphedOn = async (visibility, methodName, ...tags) => {
await visibility();
return composeParagraphed(methodName, ...tags);
}
Insert cell
marked = require("marked")
Insert cell
html`<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@primer/css@15/dist/product.css">`
Insert cell
html`<style>
h1,
h2,
h3,
p {
max-width: unset;
}

h1 {
text-transform: lowercase;
}

b,
strong {
font-weight: 600;
}

.d-none {
display: none;
}

.markdown-body > p:last-child,
.markdown-body > pre:last-child {
margin-bottom: 7px !important;
}
</style>`
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