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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more