You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

node-cron

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cron - npm Package Compare versions

Comparing version

to
4.1.0

7

dist/cjs/create-id.js

@@ -10,9 +10,6 @@ "use strict";

const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const values = new Uint8Array(length);
node_crypto_1.default.getRandomValues(values);
const values = node_crypto_1.default.randomBytes(length);
const id = Array.from(values, v => charset[v % charset.length]).join('');
if (prefix)
return `${prefix}-${id}`;
return id;
return prefix ? `${prefix}-${id}` : id;
}
//# sourceMappingURL=create-id.js.map

@@ -1,10 +0,4 @@

import { ScheduledTask, TaskFn } from "./tasks/scheduled-task";
export type Options = {
name?: string;
timezone?: string;
noOverlap?: boolean;
maxExecutions?: number;
};
export declare function schedule(expression: string, func: TaskFn | string, options?: Options): ScheduledTask;
export declare function createTask(expression: string, func: TaskFn | string, options?: Options): ScheduledTask;
import { ScheduledTask, TaskFn, TaskOptions } from "./tasks/scheduled-task";
export declare function schedule(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
export declare function createTask(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
export declare function validate(expression: string): boolean;

@@ -11,0 +5,0 @@ export { ScheduledTask } from './tasks/scheduled-task';

@@ -17,9 +17,3 @@ "use strict";

function schedule(expression, func, options) {
const taskOptions = {
name: options?.name,
timezone: options?.timezone,
noOverlap: options?.noOverlap,
maxExecutions: options?.maxExecutions
};
const task = createTask(expression, func, taskOptions);
const task = createTask(expression, func, options);
task.start();

@@ -29,15 +23,9 @@ return task;

function createTask(expression, func, options) {
const taskOptions = {
name: options?.name,
timezone: options?.timezone,
noOverlap: options?.noOverlap,
maxExecutions: options?.maxExecutions,
};
let task;
if (func instanceof Function) {
task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, taskOptions);
task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, options);
}
else {
const taskPath = solvePath(func);
task = new background_scheduled_task_1.default(expression, taskPath, taskOptions);
task = new background_scheduled_task_1.default(expression, taskPath, options);
}

@@ -44,0 +32,0 @@ registry.add(task);

@@ -11,2 +11,3 @@ import { Execution } from "../tasks/scheduled-task";

maxExecutions?: number;
maxRandomDelay?: number;
onMissedExecution?: OnFn;

@@ -24,2 +25,3 @@ onOverlap?: OnFn;

maxExecutions?: number;
maxRandomDelay: number;
runCount: number;

@@ -26,0 +28,0 @@ running: boolean;

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

maxExecutions;
maxRandomDelay;
runCount;

@@ -37,2 +38,3 @@ running;

this.maxExecutions = options?.maxExecutions;
this.maxRandomDelay = options?.maxRandomDelay || 0;
this.onMissedExecution = options?.onMissedExecution || emptyOnFn;

@@ -57,4 +59,4 @@ this.onOverlap = options?.onOverlap || emptyOnFn;

};
const checkAndRun = (date) => {
return new tracked_promise_1.TrackedPromise(async (resolve) => {
const runTask = (date) => {
return new Promise(async (resolve) => {
const execution = {

@@ -64,6 +66,7 @@ id: (0, create_id_1.createID)('exec'),

};
try {
if (this.timeMatcher.match(date)) {
const shouldExecute = await this.beforeRun(date, execution);
if (shouldExecute) {
const shouldExecute = await this.beforeRun(date, execution);
const randomDelay = Math.floor(Math.random() * this.maxRandomDelay);
if (shouldExecute) {
setTimeout(async () => {
try {
this.runCount++;

@@ -80,10 +83,18 @@ execution.startedAt = new Date();

}
}
catch (error) {
execution.finishedAt = new Date();
execution.error = error;
this.onError(date, error, execution);
}
resolve(true);
}, randomDelay);
}
});
};
const checkAndRun = (date) => {
return new tracked_promise_1.TrackedPromise(async (resolve) => {
if (this.timeMatcher.match(date)) {
await runTask(date);
resolve(true);
}
catch (error) {
execution.finishedAt = new Date();
execution.error = error;
this.onError(date, error, execution);
}
});

@@ -90,0 +101,0 @@ };

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

maxExecutions: options?.maxExecutions,
maxRandomDelay: options?.maxRandomDelay,
beforeRun: (date, execution) => {

@@ -39,0 +40,0 @@ if (execution.reason === 'scheduled') {

@@ -14,2 +14,3 @@ export type TaskContext = {

maxExecutions?: number;
maxRandomDelay?: number;
};

@@ -16,0 +17,0 @@ export type Execution = {

@@ -10,9 +10,6 @@ "use strict";

const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const values = new Uint8Array(length);
node_crypto_1.default.getRandomValues(values);
const values = node_crypto_1.default.randomBytes(length);
const id = Array.from(values, v => charset[v % charset.length]).join('');
if (prefix)
return `${prefix}-${id}`;
return id;
return prefix ? `${prefix}-${id}` : id;
}
//# sourceMappingURL=create-id.js.map

@@ -1,10 +0,4 @@

import { ScheduledTask, TaskFn } from "./tasks/scheduled-task";
export type Options = {
name?: string;
timezone?: string;
noOverlap?: boolean;
maxExecutions?: number;
};
export declare function schedule(expression: string, func: TaskFn | string, options?: Options): ScheduledTask;
export declare function createTask(expression: string, func: TaskFn | string, options?: Options): ScheduledTask;
import { ScheduledTask, TaskFn, TaskOptions } from "./tasks/scheduled-task";
export declare function schedule(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
export declare function createTask(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
export declare function validate(expression: string): boolean;

@@ -11,0 +5,0 @@ export { ScheduledTask } from './tasks/scheduled-task';

@@ -17,9 +17,3 @@ "use strict";

function schedule(expression, func, options) {
const taskOptions = {
name: options?.name,
timezone: options?.timezone,
noOverlap: options?.noOverlap,
maxExecutions: options?.maxExecutions
};
const task = createTask(expression, func, taskOptions);
const task = createTask(expression, func, options);
task.start();

@@ -29,15 +23,9 @@ return task;

function createTask(expression, func, options) {
const taskOptions = {
name: options?.name,
timezone: options?.timezone,
noOverlap: options?.noOverlap,
maxExecutions: options?.maxExecutions,
};
let task;
if (func instanceof Function) {
task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, taskOptions);
task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, options);
}
else {
const taskPath = solvePath(func);
task = new background_scheduled_task_1.default(expression, taskPath, taskOptions);
task = new background_scheduled_task_1.default(expression, taskPath, options);
}

@@ -44,0 +32,0 @@ registry.add(task);

@@ -11,2 +11,3 @@ import { Execution } from "../tasks/scheduled-task";

maxExecutions?: number;
maxRandomDelay?: number;
onMissedExecution?: OnFn;

@@ -24,2 +25,3 @@ onOverlap?: OnFn;

maxExecutions?: number;
maxRandomDelay: number;
runCount: number;

@@ -26,0 +28,0 @@ running: boolean;

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

maxExecutions;
maxRandomDelay;
runCount;

@@ -37,2 +38,3 @@ running;

this.maxExecutions = options?.maxExecutions;
this.maxRandomDelay = options?.maxRandomDelay || 0;
this.onMissedExecution = options?.onMissedExecution || emptyOnFn;

@@ -57,4 +59,4 @@ this.onOverlap = options?.onOverlap || emptyOnFn;

};
const checkAndRun = (date) => {
return new tracked_promise_1.TrackedPromise(async (resolve) => {
const runTask = (date) => {
return new Promise(async (resolve) => {
const execution = {

@@ -64,6 +66,7 @@ id: (0, create_id_1.createID)('exec'),

};
try {
if (this.timeMatcher.match(date)) {
const shouldExecute = await this.beforeRun(date, execution);
if (shouldExecute) {
const shouldExecute = await this.beforeRun(date, execution);
const randomDelay = Math.floor(Math.random() * this.maxRandomDelay);
if (shouldExecute) {
setTimeout(async () => {
try {
this.runCount++;

@@ -80,10 +83,18 @@ execution.startedAt = new Date();

}
}
catch (error) {
execution.finishedAt = new Date();
execution.error = error;
this.onError(date, error, execution);
}
resolve(true);
}, randomDelay);
}
});
};
const checkAndRun = (date) => {
return new tracked_promise_1.TrackedPromise(async (resolve) => {
if (this.timeMatcher.match(date)) {
await runTask(date);
resolve(true);
}
catch (error) {
execution.finishedAt = new Date();
execution.error = error;
this.onError(date, error, execution);
}
});

@@ -90,0 +101,0 @@ };

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

maxExecutions: options?.maxExecutions,
maxRandomDelay: options?.maxRandomDelay,
beforeRun: (date, execution) => {

@@ -39,0 +40,0 @@ if (execution.reason === 'scheduled') {

@@ -14,2 +14,3 @@ export type TaskContext = {

maxExecutions?: number;
maxRandomDelay?: number;
};

@@ -16,0 +17,0 @@ export type Execution = {

{
"name": "node-cron",
"version": "4.0.7",
"version": "4.1.0",
"description": "A Lightweight Task Scheduler for Node.js",

@@ -5,0 +5,0 @@ "author": "Lucas Merencia",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet