Published
Edited
Mar 21, 2020
Insert cell
Insert cell
page1 = d3.json('https://kb.twopointzero.us/datasets/db-page-1.json')
Insert cell
page2 = d3.json('https://kb.twopointzero.us/datasets/db-page-2.json')
Insert cell
rawPosts = [...page1, ...page2].reverse()
Insert cell
re = /^(?:[Cc][Ww]: (?<cw>.+)[\n-.]+)?"?(?:(?<id>\d+)(?<verified>\*)?\s*-\s*)?(?<content>[\s\S]+)"?$/
Insert cell
bad = posts.filter(p => typeof p === 'string')
Insert cell
posts = rawPosts
.map(p => (p.match(re) || { groups: p }).groups)
.map(({ cw, id, verified, content }) => ({
cw: cw || null,
id,
verified: !!verified,
content
}))
Insert cell
posts

Insert cell
d3 = require('d3@5')
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