Public
Edited
Jan 17
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { zipreader } from "@fil/jszip"
Insert cell
book = zipreader(f)
Insert cell
chapters = Promise.all(
Array.from(book)
.filter(([d]) => d.match(/\.(x?html)$/))
.map(([, p]) => p)
)
Insert cell
texts = chapters.map(text)
Insert cell
function text(x) {
const div = document.createElement("div");
div.innerHTML = x;
return (div.textContent || div.innerText || "")
.replaceAll(/\s+/g, " ")
.trim();
}
Insert cell
counts = texts
.filter((text) => text.toLowerCase().startsWith(start.toLowerCase()))
.map((text) => ({ text, words: text.split(/\s+/g).length }))
Insert cell
totalWords = d3.sum(counts, ({ words }) => words)
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