js-awe
Version:
Awesome js utils including - plan: An Asynchronous control flow with a functional taste - Chrono: record and visualize timelines in the console
59 lines (49 loc) • 869 B
JavaScript
import { Chrono, sleepWithFunction } from './js-awe.min.js'
let chrono = Chrono()
chrono.time('step1')
tasks().then(()=>{
chrono.timeEnd('step1')
const newDiv = document.createElement('div');
newDiv.innerHTML = `<pre>${chrono.timelineLines()}</pre>`;
document.body.appendChild(newDiv);
chrono.report()
})
async function tasks()
{
await sleepWithFunction(
650,
() => {
chrono.timeEnd('step1')
}
)
await sleepWithFunction(
20,
() => {
chrono.time('step2')
}
)
await sleepWithFunction(
12,
() => {
chrono.time('step3')
}
)
await sleepWithFunction(
500,
() => {
chrono.timeEnd('step3')
}
),
await sleepWithFunction(
100,
() => {
chrono.timeEnd('step2')
}
),
await sleepWithFunction(
15,
() => {
chrono.time('step1')
}
)
}