Skip to content

Commit

Permalink
Add API for checking the task is exist without throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattia lau authored and mattia lau committed Jan 5, 2021
1 parent 5cff069 commit bbdcab4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/scheduler.registry.ts
Expand Up @@ -8,6 +8,19 @@ export class SchedulerRegistry {
private readonly timeouts = new Map<string, any>();
private readonly intervals = new Map<string, any>();

isExists(type: 'cron' | 'timeout' | 'interval', name: string) {
switch (type) {
case 'cron':
return this.cronJobs.has(name);
case 'interval':
return this.intervals.has(name);
case 'timeout':
return this.timeouts.has(name);
default:
return false;
}
}

getCronJob(name: string) {
const ref = this.cronJobs.get(name);
if (!ref) {
Expand Down

0 comments on commit bbdcab4

Please sign in to comment.