import { isCron, Cron } from "#Source/cron/index.ts" export interface TaskOptions { name: string cron: Cron | string | Date run: (() => void) | (() => Promise) } export class Task { protected options: TaskOptions protected cron: Cron constructor(options: TaskOptions) { this.options = options if (isCron(options.cron) === true) { this.cron = options.cron } else { this.cron = new Cron({ pattern: options.cron }) } } getName(): string { return this.options.name } getCron(): Cron { return this.cron } async run(): Promise { await this.options.run() } }