Published
Edited
Jun 4, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sleep = x => d =>
new Promise((res, rej) => {
setTimeout(() => res(d), x);
})
Insert cell
Insert cell
calcTimeDelta = start => Date.now() - start
Insert cell
start = _ => Date.now()
Insert cell
sleepPipe = pipe(
timeDisplay,
sleep(1000),
timeDisplay,
sleep(1000),
timeDisplay,
sleep(2000),
timeDisplay
)
Insert cell
md`### _sleepPipe()_ proof`
Insert cell
fmtTimeDelta = start => `${calcTimeDelta(start)} ms elapsed`
Insert cell
{
const ts = start();
yield print(fmtTimeDelta(ts));
yield print(fmtTimeDelta(await sleepPipe(ts)));
}
Insert cell
timeDisplay = start => {
console.log(fmtTimeDelta(start));
return start;
}
Insert cell
trace = label => d => {
console.log(`${label}: ${d}`);
return d;
}
Insert cell
print = x => `output: ${x}`
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