cron

  • Version 4.4.2
  • Published
  • 190 kB
  • 2 dependencies
  • MIT license

Install

npm i cron
yarn add cron
pnpm add cron

Overview

Cron jobs for your node

Index

Variables

variable validateCronExpression

const validateCronExpression: (cronExpression: string) => {
valid: boolean;
error?: CronError;
};

    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?: number,
          unrefTimeout?: boolean,
          waitForCompletion?: boolean,
          errorHandler?: (error: unknown) => void,
          name?: string,
          threshold?: number
          );

            property context

            context: {};

              property cronTime

              cronTime: CronTime;

                property errorHandler

                errorHandler?: (error: unknown) => void;

                  property isActive

                  readonly isActive: boolean;

                    property isCallbackRunning

                    readonly isCallbackRunning: boolean;

                      property lastExecution

                      lastExecution: Date;

                        property name

                        name?: string;

                          property onComplete

                          onComplete?: CronOnCompleteCallback;

                            property runOnce

                            runOnce: boolean;

                              property threshold

                              threshold: number;

                                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: () => Promise<void> | undefined;

                                                      class CronTime

                                                      class CronTime {}

                                                        constructor

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

                                                          property realDate

                                                          realDate: boolean;

                                                            property source

                                                            source: any;

                                                              property timeZone

                                                              timeZone?: string;

                                                                property utcOffset

                                                                utcOffset?: number;

                                                                  method getNextDateFrom

                                                                  getNextDateFrom: (
                                                                  start: Date | CustomDateTime,
                                                                  timeZone?: string | CustomZone
                                                                  ) => DateTime;

                                                                    method getTimeout

                                                                    getTimeout: () => number;

                                                                      method sendAt

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

                                                                        method toJSON

                                                                        toJSON: () => string[];

                                                                          method toString

                                                                          toString: () => string;

                                                                            method validateCronExpression

                                                                            static validateCronExpression: (cronExpression: string) => {
                                                                            valid: boolean;
                                                                            error?: CronError;
                                                                            };

                                                                              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 (29)

                                                                                                          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>