cron

  • Version 3.3.1
  • Published
  • 121 kB
  • 2 dependencies
  • MIT license

Install

npm i cron
yarn add cron
pnpm add cron

Overview

Cron jobs for your node

Index

Functions

function sendAt

sendAt: (cronTime: string | Date | DateTime) => DateTime;

    function timeout

    timeout: (cronTime: string | Date | DateTime) => number;

      Classes

      class CronJob

      class CronJob<OC extends CronOnCompleteCommand | null = null, C = null> {}

        constructor

        constructor(
        cronTime: any,
        onTick: CronCommand<C, WithOnComplete<OC>>,
        onComplete?: CronOnCompleteCommand,
        start?: boolean,
        timeZone?: string,
        context?: {},
        runOnInit?: boolean,
        utcOffset?: null,
        unrefTimeout?: boolean,
        waitForCompletion?: boolean
        );

          constructor

          constructor(
          cronTime: any,
          onTick: CronCommand<C, WithOnComplete<OC>>,
          onComplete?: CronOnCompleteCommand,
          start?: boolean,
          timeZone?: null,
          context?: {},
          runOnInit?: boolean,
          utcOffset?: number,
          unrefTimeout?: boolean,
          waitForCompletion?: boolean
          );

            property context

            context: {};

              property cronTime

              cronTime: CronTime;

                property isCallbackRunning

                readonly isCallbackRunning: boolean;

                  property lastExecution

                  lastExecution: Date;

                    property onComplete

                    onComplete?: CronOnCompleteCallback;

                      property running

                      running: boolean;

                        property runOnce

                        runOnce: boolean;

                          property unrefTimeout

                          unrefTimeout: boolean;

                            property waitForCompletion

                            waitForCompletion: boolean;

                              method addCallback

                              addCallback: (callback: CronCallback<C, WithOnComplete<OC>>) => void;

                                method fireOnTick

                                fireOnTick: () => Promise<void>;

                                  method from

                                  static from: <OC extends CronOnCompleteCommand = null, C = null>(
                                  params: CronJobParams<OC, C>
                                  ) => CronJob<OC, C>;

                                    method lastDate

                                    lastDate: () => Date | null;

                                      method nextDate

                                      nextDate: () => any;

                                        method nextDates

                                        nextDates: (i?: number) => import('luxon').DateTime<boolean>[];

                                          method setTime

                                          setTime: (time: CronTime) => void;

                                            method start

                                            start: () => void;

                                              method stop

                                              stop: () => void;

                                                class CronTime

                                                class CronTime {}

                                                  constructor

                                                  constructor(source: any, timeZone?: string, utcOffset?: null);

                                                    constructor

                                                    constructor(source: any, timeZone?: null, utcOffset?: number);

                                                      property realDate

                                                      realDate: boolean;

                                                        property source

                                                        source: any;

                                                          property timeZone

                                                          timeZone?: string;

                                                            property utcOffset

                                                            utcOffset?: number;

                                                              method getNextDateFrom

                                                              getNextDateFrom: (
                                                              start: Date | DateTime,
                                                              timeZone?: string | Zone
                                                              ) => DateTime<boolean>;

                                                                method getTimeout

                                                                getTimeout: () => number;

                                                                  method sendAt

                                                                  sendAt: { (): DateTime; (i: number): DateTime[] };

                                                                    method toJSON

                                                                    toJSON: () => string[];

                                                                      method toString

                                                                      toString: () => string;

                                                                        Interfaces

                                                                        interface Ranges

                                                                        interface Ranges {}

                                                                          property dayOfMonth

                                                                          dayOfMonth: DayOfMonthRange;

                                                                            property dayOfWeek

                                                                            dayOfWeek: DayOfWeekRange;

                                                                              property hour

                                                                              hour: HourRange;

                                                                                property minute

                                                                                minute: MinuteRange;

                                                                                  property month

                                                                                  month: MonthRange;

                                                                                    property second

                                                                                    second: SecondRange;

                                                                                      Type Aliases

                                                                                      type CronCallback

                                                                                      type CronCallback<C, WithOnCompleteBool extends boolean = false> = (
                                                                                      this: CronContext<C>,
                                                                                      onComplete: WithOnCompleteBool extends true ? CronOnCompleteCallback : never
                                                                                      ) => void | Promise<void>;

                                                                                        type CronCommand

                                                                                        type CronCommand<C, WithOnCompleteBool extends boolean = false> =
                                                                                        | CronCallback<C, WithOnCompleteBool>
                                                                                        | CronSystemCommand;

                                                                                          type CronContext

                                                                                          type CronContext<C> = C extends null ? CronJob : NonNullable<C>;

                                                                                            type CronJobParams

                                                                                            type CronJobParams<
                                                                                            OC extends CronOnCompleteCommand | null = null,
                                                                                            C = null
                                                                                            > = BaseCronJobParams<OC, C> &
                                                                                            (
                                                                                            | {
                                                                                            timeZone?: string | null;
                                                                                            utcOffset?: never;
                                                                                            }
                                                                                            | {
                                                                                            timeZone?: never;
                                                                                            utcOffset?: number | null;
                                                                                            }
                                                                                            );

                                                                                              type CronOnCompleteCallback

                                                                                              type CronOnCompleteCallback = () => void | Promise<void>;

                                                                                                type CronOnCompleteCommand

                                                                                                type CronOnCompleteCommand = CronOnCompleteCallback | CronSystemCommand;

                                                                                                  type TimeUnit

                                                                                                  type TimeUnit = (typeof TIME_UNITS_MAP)[keyof typeof TIME_UNITS_MAP];

                                                                                                    Package Files (4)

                                                                                                    Dependencies (2)

                                                                                                    Dev Dependencies (28)

                                                                                                    Peer Dependencies (0)

                                                                                                    No peer dependencies.

                                                                                                    Badge

                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/cron.

                                                                                                    • Markdown
                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/cron)
                                                                                                    • HTML
                                                                                                      <a href="https://www.jsdocs.io/package/cron"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>