Socket
Socket
Sign inDemoInstall

cron

Package Overview
Dependencies
Maintainers
3
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cron - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

13

CHANGELOG.md

@@ -0,1 +1,14 @@

## [3.1.1](https://github.com/kelektiv/node-cron/compare/v3.1.0...v3.1.1) (2023-10-12)
### 🐛 Bug Fixes
* fix lastDate() value for intervals > 25 days ([#711](https://github.com/kelektiv/node-cron/issues/711)) ([141aa00](https://github.com/kelektiv/node-cron/commit/141aa00f55fa105d89df7e257d82c94ad2bb2b3a))
* fix object constructor typings & make OC generic type optional ([#712](https://github.com/kelektiv/node-cron/issues/712)) ([6536084](https://github.com/kelektiv/node-cron/commit/653608451caecd51f50884d83563c03c6c27bc54))
### 📚 Documentation
* **readme:** update nextDates documentation ([#702](https://github.com/kelektiv/node-cron/issues/702)) ([1ad2e22](https://github.com/kelektiv/node-cron/commit/1ad2e228f75bcaab3eb97a27665c06b7892678c5))
## [3.1.0](https://github.com/kelektiv/node-cron/compare/v3.0.0...v3.1.0) (2023-10-09)

@@ -2,0 +15,0 @@

6

dist/job.d.ts
import { CronTime } from './time';
import { CronCallback, CronContext, CronJobParams, CronOnCompleteCallback, CronOnCompleteCommand, WithOnComplete } from './types/cron.types';
export declare class CronJob<OC extends CronOnCompleteCommand<C> | null, C = null> {
export declare class CronJob<OC extends CronOnCompleteCommand | null = null, C = null> {
cronTime: CronTime;

@@ -10,3 +10,3 @@ running: boolean;

context: CronContext<C>;
onComplete?: WithOnComplete<OC> extends true ? CronOnCompleteCallback<C> : undefined;
onComplete?: WithOnComplete<OC> extends true ? CronOnCompleteCallback : undefined;
private _timeout?;

@@ -16,3 +16,3 @@ private _callbacks;

constructor(cronTime: CronJobParams<OC, C>['cronTime'], onTick: CronJobParams<OC, C>['onTick'], onComplete?: CronJobParams<OC, C>['onComplete'], start?: CronJobParams<OC, C>['start'], timeZone?: null, context?: CronJobParams<OC, C>['context'], runOnInit?: CronJobParams<OC, C>['runOnInit'], utcOffset?: CronJobParams<OC, C>['utcOffset'], unrefTimeout?: CronJobParams<OC, C>['unrefTimeout']);
static from<C = null, OC extends CronOnCompleteCommand<C> | null = null>(params: CronJobParams<OC, C>): CronJob<OC, C>;
static from<OC extends CronOnCompleteCommand | null = null, C = null>(params: CronJobParams<OC, C>): CronJob<OC, C>;
private _fnWrap;

@@ -19,0 +19,0 @@ addCallback(callback: CronCallback<C, WithOnComplete<OC>>): void;

@@ -123,3 +123,2 @@ "use strict";

}
this.lastExecution = new Date();
if (remaining) {

@@ -137,2 +136,3 @@ if (remaining > MAXDELAY) {

else {
this.lastExecution = new Date();
this.running = false;

@@ -139,0 +139,0 @@ if (!this.runOnce) {

@@ -14,4 +14,4 @@ import { DateTime, Zone } from 'luxon';

private dayOfWeek;
constructor(source: CronJobParams<null>['cronTime'], timeZone?: CronJobParams<null>['timeZone'], utcOffset?: null);
constructor(source: CronJobParams<null>['cronTime'], timeZone?: null, utcOffset?: CronJobParams<null>['utcOffset']);
constructor(source: CronJobParams['cronTime'], timeZone?: CronJobParams['timeZone'], utcOffset?: null);
constructor(source: CronJobParams['cronTime'], timeZone?: null, utcOffset?: CronJobParams['utcOffset']);
private _getWeekDay;

@@ -18,0 +18,0 @@ private _verifyParse;

@@ -7,3 +7,3 @@ /// <reference types="node" />

import { IntRange } from './utils';
interface BaseCronJobParams<OC extends CronOnCompleteCommand<C> | null, C = null> {
interface BaseCronJobParams<OC extends CronOnCompleteCommand | null = null, C = null> {
cronTime: string | Date | DateTime;

@@ -17,3 +17,3 @@ onTick: CronCommand<C, WithOnComplete<OC>>;

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

@@ -25,5 +25,5 @@ utcOffset?: never;

});
export type CronContext<C> = C extends null ? CronJob<null> : NonNullable<C>;
export type CronCallback<C, WithOnCompleteBool extends boolean = false> = (this: CronContext<C>, onComplete: WithOnCompleteBool extends true ? OmitThisParameter<CronOnCompleteCallback<C>> : never) => void;
export type CronOnCompleteCallback<C> = (this: CronContext<C>) => void;
export type CronContext<C> = C extends null ? CronJob : NonNullable<C>;
export type CronCallback<C, WithOnCompleteBool extends boolean = false> = (this: CronContext<C>, onComplete: WithOnCompleteBool extends true ? CronOnCompleteCallback : never) => void;
export type CronOnCompleteCallback = () => void;
export type CronSystemCommand = string | {

@@ -35,3 +35,3 @@ command: string;

export type CronCommand<C, WithOnCompleteBool extends boolean = false> = CronCallback<C, WithOnCompleteBool> | CronSystemCommand;
export type CronOnCompleteCommand<C> = OmitThisParameter<CronOnCompleteCallback<C>> | CronSystemCommand;
export type CronOnCompleteCommand = CronOnCompleteCallback | CronSystemCommand;
export type WithOnComplete<OC> = OC extends null ? false : true;

@@ -38,0 +38,0 @@ export type TimeUnit = (typeof TIME_UNITS_MAP)[keyof typeof TIME_UNITS_MAP];

{
"name": "cron",
"description": "Cron jobs for your node",
"version": "3.1.0",
"version": "3.1.1",
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)",

@@ -6,0 +6,0 @@ "bugs": {

@@ -47,2 +47,3 @@ <p align="center">

- **callbacks are now called in the order they were registered.**
- **`nextDates(count?: number)` now always returns an array (empty if no argument is provided). Use `nextDate()` instead for a single date.**

@@ -122,3 +123,3 @@ ### Removed methods

- `onTick` - [REQUIRED] - The function to fire at the specified time. If an `onComplete` callback was provided, `onTick` will receive it as an argument. `onTick` may call `onComplete` when it has finished its work.
- `onComplete` - [OPTIONAL] - A function that will fire when the job is stopped with `job.stop()`, and may also be called by `onTick` at the end of each run.
- `onComplete` - [OPTIONAL] - A function that will fire when the job is stopped with `job.stop()`, and may also be called by `onTick` at the end of each run. **Note for TS users**: This should either be an arrow function, or a regular function cast to `() => void` (bug with generic type inference).
- `start` - [OPTIONAL] - Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call `job.start()` in order to start the job (assuming `job` is the variable you set the cronjob to). This does not immediately fire your `onTick` function, it just gives you more control over the behavior of your jobs.

@@ -136,3 +137,4 @@ - `timeZone` - [OPTIONAL] - Specify the time zone for the execution. This will modify the actual time relative to your time zone. If the time zone is invalid, an error is thrown. By default (if this is omitted) the local time zone will be used. You can check the various time zones format accepted in the [Luxon documentation](https://github.com/moment/luxon/blob/master/docs/zones.md#specifying-a-zone). Note: This parameter supports minutes offsets, e.g. `UTC+5:30`. **Note**: Cannot be used together with `utcOffset`.

- `nextDate` - Provides the next date that will trigger an `onTick`.
- `nextDates` - Provides an array of the next set of dates that will trigger an `onTick`.
- `nextDates(count)` - Provides an array of the next set of dates that will trigger an `onTick`.
- `count` - [OPTIONAL] - The number of next dates to return. Defaults to 0, returning an empty array.
- `fireOnTick` - Allows you to override the `onTick` calling behavior. This matters so only do this if you have a really good reason to do so.

@@ -139,0 +141,0 @@ - `addCallback` - Allows you to add `onTick` callbacks. Callbacks are run in the order they are registered.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc