Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 907 Bytes

README.md

File metadata and controls

36 lines (26 loc) · 907 Bytes

chronos

Chronos - Task Scheduler

Chronos is a simple task scheduler library for Deno that allows you to schedule and run tasks at specific intervals or times.

Usage

Here's an example of how to use the Chronos Task Scheduler:

import {
  createTask,
  IntervalScheduler,
  Task,
} from "https://deno.land/x/[email protected]/src/mod.ts";

// Define a task action
const taskAction = async () => {
  console.log("Task executed:", new Date());
};

// Create a task to be executed in 5 seconds
const dueTime = new Date(Date.now() + 5000);
const task = createTask("exampleTask", taskAction, dueTime, 1000);

// Create an IntervalScheduler instance
const scheduler = new IntervalScheduler();

// Schedule the task
scheduler.schedule(task);

// You can unschedule the task if necessary
scheduler.unschedule(task.id);