Published
Edited
Apr 5, 2020
Importers
1 star
Insert cell
Insert cell
formatInt = value => new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(value)
Insert cell
formatFloat = value => new Intl.NumberFormat('en-US').format(value)
Insert cell
offset = (i, start, step) => start + i * step;
Insert cell
range = n => new Array(n).fill(undefined).map((_, i) => i)
Insert cell
uniq = items => Array.from(new Set(items))
Insert cell
randomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min
Insert cell
randomString = () => Math.floor(Math.random() * 10e12).toString(36)
Insert cell
randomUuid = () => {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
const r = (Math.random() * 16) | 0;
const v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
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