async function initTimerExample() {
const { Timer } = await import('../dist/clock_timer.js');
console.log("Timer Example");
try {
const timer = new Timer(0, 0, 10);
console.log(`Timer created with duration: ${timer.duration} seconds`);
console.log(`Hours: ${timer.hours}, Minutes: ${timer.minutes}, Seconds: ${timer.seconds}`);
console.log("Starting timer...");
await timer.start();
console.log("Timer completed!");
} catch (error) {
console.error("Timer error:", error);
}
}
async function initStopwatchExample() {
const { Stopwatch } = await import('../dist/clock_timer.js');
console.log("Stopwatch Example");
const stopwatch = new Stopwatch();
console.log("Starting stopwatch...");
stopwatch.start();
await new Promise(resolve => setTimeout(resolve, 5000));
const elapsed = stopwatch.stop();
console.log(`Stopwatch stopped at ${elapsed} seconds`);
stopwatch.reset();
console.log("Stopwatch reset");
}
async function runExamples() {
await initTimerExample();
console.log("\n-------------------\n");
await initStopwatchExample();
}
runExamples().catch(console.error);