Published
Edited
Dec 1, 2021
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
_fetch = mode === "Write" ? writeMemoFetch : readMemoFetch(cache)
Insert cell
Insert cell
prs = (
await _fetch(
"https://api.github.com/repos/observablehq/plot/pulls?per_page=5"
)
).json()
Insert cell
commits = Promise.all(prs.map(async (pr) =>
(
await _fetch(
`https://api.github.com/repos/observablehq/plot/pulls/${pr.number}/commits`
)
).json()
))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cache = FileAttachment("fetchCache (5).zip").zip()
Insert cell
Insert cell
Insert cell
readMemoFetch = (zip) => (resource, init) =>
zip.filenames.includes(encodeURIComponent(resource))
? zip.file(encodeURIComponent(resource))
: fetch(resource, init)
Insert cell
writeMemoFetch = async (resource, init) => {
const text = await (await fetch(resource, init)).text();
zip.file(encodeURIComponent(resource), text);
mutable files = mutable files + 1;
return {
json: () => new Promise((resolve) => resolve(JSON.parse(text))),
text: () => new Promise((resolve) => resolve(text))
};
}
Insert cell
mutable files = 0
Insert cell
keys = (files, Object.keys(zip.files))
Insert cell
zip = (reset, new jszip.default())
Insert cell
blob = (files, zip.generateAsync({ type: "blob" }))
Insert cell
jszip = import("https://cdn.skypack.dev/jszip@3.7.0?min")
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