Public
Edited
Jul 19, 2023
Insert cell
Insert cell
elements = [1, 5, true, "hello", "world", "toph", "tucker", ""]
Insert cell
Insert cell
arr = reshuffle, d3.range(10).map(() => d3.shuffle(elements)[0])
Insert cell
Insert cell
Insert cell
combine(arr)
Insert cell
combine = (arr) => {
let strBuffer = null;
const combined = [];
for (let i = 0; i < arr.length; i++) {
const d = arr[i];
if (typeof d === "string") {
if (!i || strBuffer === null) {
strBuffer = d;
} else {
strBuffer += d;
}
} else {
if (strBuffer !== null) {
combined.push(strBuffer);
strBuffer = null;
}
combined.push(d);
}
}
if (strBuffer !== null) combined.push(strBuffer);
return combined;
}
Insert cell
Insert cell
elements1 = [
{
type: "section",
text: { type: "mrkdwn", text: "Hello world" }
},
{
type: "context",
elements: [{ type: "mrkdwn", text: "Footer" }]
},
new Blob()
]
Insert cell
Insert cell
arr1 = reshuffle1, d3.range(10).map(() => d3.shuffle(elements1)[0])
Insert cell
Insert cell
Insert cell
combine1(arr1)
Insert cell
combine1 = (arr) => {
let blockBuffer = [];
const combined = [];
for (let i = 0; i < arr.length; i++) {
const d = arr[i];
if (!(d instanceof Blob)) {
blockBuffer.push(d);
} else {
if (blockBuffer.length) {
combined.push(blockBuffer);
blockBuffer = [];
}
combined.push(d);
}
}
if (blockBuffer.length) combined.push(blockBuffer);
return combined;
}
Insert cell
Insert cell
Insert cell
Insert cell
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