Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CronDaemon

Execute a cron schedule. The Daemon is initialized in the "started" state.

param

Cron schedule string e.g. 0,30 9-17 * * MON-FRI or custom function to calculate the next date.

param

Function to be invoked on the schedule.

throws

If the schedule string is not valid cron syntax.

Hierarchy

  • CronDaemon

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Private Readonly callback

callback: (date: Date) => void

Type declaration

    • (date: Date): void
    • Parameters

      • date: Date

      Returns void

Private Readonly schedule

schedule: Schedule | CustomSchedule

Private Optional timeout

timeout: ReturnType<typeof setTimeout>

Methods

next

  • next(): Date | undefined
  • Get the next occurance in the schedule.

    Returns Date | undefined

    The next instant when the daemon will execute the callback or undefined if the schedule has no more possible instances.

start

  • start(): void

state

  • state(): "running" | "stopped"
  • Current state of the daemon.

    Returns "running" | "stopped"

    running or stopped

stop

  • stop(): void
  • Stops the daemon running the schedule

    Returns void

Generated using TypeDoc