import { Timer, Stopwatch } from "rust-ticker";
async function runExamples() {
try {
console.log("Example 1: Creating a 5-second timer");
const timer = new Timer(0, 0, 5); console.log("Starting timer...");
await timer.start();
console.log("Timer completed!");
console.log("\nExample 2: Using a stopwatch");
const stopwatch = new Stopwatch();
console.log("Starting stopwatch...");
await stopwatch.start();
console.log("Waiting for 3 seconds...");
await new Promise((resolve) => setTimeout(resolve, 3000));
const elapsed = await stopwatch.stop();
console.log(`Stopwatch stopped at ${elapsed} seconds`);
console.log("Resetting stopwatch...");
await stopwatch.reset();
console.log("\nExamples completed!");
} catch (error) {
console.error("Error running examples:", error);
}
}
runExamples();