Socket
Socket
Sign inDemoInstall

toad-scheduler

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0

4

dist/lib/common/AsyncTask.d.ts

@@ -6,4 +6,4 @@ export declare class AsyncTask {

private readonly errorHandler;
constructor(id: string, handler: () => Promise<unknown>, errorHandler?: (err: Error) => void);
execute(): void;
constructor(id: string, handler: (taskId?: string, jobId?: string) => Promise<unknown>, errorHandler?: (err: Error) => void);
execute(jobId?: string): void;
}

@@ -13,5 +13,5 @@ "use strict";

}
execute() {
execute(jobId) {
this.isExecuting = true;
this.handler()
this.handler(this.id, jobId)
.catch((err) => {

@@ -18,0 +18,0 @@ const errorHandleResult = this.errorHandler(err);

@@ -6,4 +6,4 @@ export declare class Task {

private readonly errorHandler;
constructor(id: string, handler: () => void, errorHandler?: (err: Error) => void);
execute(): void;
constructor(id: string, handler: (taskId?: string, jobId?: string) => void, errorHandler?: (err: Error) => void);
execute(jobId?: string): void;
}

@@ -13,6 +13,6 @@ "use strict";

}
execute() {
execute(jobId) {
this.isExecuting = true;
try {
this.handler();
this.handler(this.id, jobId);
}

@@ -19,0 +19,0 @@ catch (err) {

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

}
/* istanbul ignore next */
getStatus() {

@@ -26,2 +27,3 @@ var _a;

const croner = require('croner');
/* istanbul ignore if */
if (!croner) {

@@ -34,6 +36,7 @@ throw new Error('Please install "croner" (run "npm i croner") in case you want to use Cron jobs.');

if (!this.task.isExecuting || !this.preventOverrun) {
this.task.execute();
this.task.execute(this.id);
}
});
}
/* istanbul ignore next */
stop() {

@@ -40,0 +43,0 @@ var _a;

@@ -47,3 +47,3 @@ "use strict";

this.setTimeEatingJob((0, SimpleIntervalSchedule_1.toMsecs)(this.schedule));
return this.task.execute();
return this.task.execute(this.id);
}));

@@ -69,7 +69,7 @@ this.childJob.start();

if (this.schedule.runImmediately) {
this.task.execute();
this.task.execute(this.id);
}
this.timer = setInterval(() => {
if (!this.task.isExecuting || !this.preventOverrun) {
this.task.execute();
this.task.execute(this.id);
}

@@ -76,0 +76,0 @@ }, time);

@@ -25,7 +25,7 @@ "use strict";

if (this.schedule.runImmediately) {
this.task.execute();
this.task.execute(this.id);
}
this.timer = setInterval(() => {
if (!this.task.isExecuting || !this.preventOverrun) {
this.task.execute();
this.task.execute(this.id);
}

@@ -32,0 +32,0 @@ }, time);

import { SimpleIntervalJob } from './engines/simple-interval/SimpleIntervalJob';
import { Job } from './common/Job';
import { Job, JobStatus } from './common/Job';
import { LongIntervalJob } from './engines/simple-interval/LongIntervalJob';

@@ -20,2 +20,4 @@ import { CronJob } from './engines/cron/CronJob';

startById(id: string): void;
getAllJobs(): Job[];
getAllJobsByStatus(status: JobStatus): Job[];
}

@@ -75,4 +75,12 @@ "use strict";

}
getAllJobs() {
return Object.values(this.jobRegistry);
}
getAllJobsByStatus(status) {
return Object.values(this.jobRegistry).filter((value) => {
return value.getStatus() === status;
});
}
}
exports.ToadScheduler = ToadScheduler;
//# sourceMappingURL=toadScheduler.js.map
{
"name": "toad-scheduler",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "In-memory Node.js and browser job scheduler",

@@ -8,3 +8,3 @@ # toad-scheduler

In-memory TypeScript job scheduler that repeatedly executes given tasks within specified intervals of time (e. g. "each 20 seconds").
In-memory TypeScript job scheduler that repeatedly executes given tasks within specified intervals of time (e. g. "each 20 seconds"). Cron syntax is also supported in case you need it.

@@ -164,3 +164,3 @@ Node.js 12+ and modern browsers are supported

```ts
import { randomUUID } from 'crypto'
import { randomUUID } from 'node:crypto'

@@ -308,2 +308,4 @@ import type { Redis } from 'ioredis'

* `existsById(id: string): boolean` - returns true if job with given id exists, false otherwise.
* `getAllJobs(): Job[]` - returns all registered jobs.
* `getAllJobsByStatus(status: JobStatus): Job[]` - returns all registered jobs with a given status.
* `stopById(id: string): void` - stops the job with a given id.

@@ -310,0 +312,0 @@ * `removeById(id: string): Job | undefined` - stops the job with a given id and removes it from the scheduler. If no such job exists, returns `undefined`, otherwise returns the job.

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc