diff --git a/README.md b/README.md index 4afbbe6..83ce99f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ cron('1 */30 3,6,9 1-7 */1 1', () => { | `biweekly(job)` | **job: func** `required` - function to be executed | | `monthly(job, dayOfMonth)` | **job: func** `required` - function to be executed, **dayOfMonth: string** or **number** **{optional}** - 1-31, `default:` **1** | | `yearly(job)` | **job: func** **required** - function to be executed | +| `stop()` | - Stop all the scheduled job | +| `start()` | - If schedulers have been stopped before then starts again | ## Change Log: diff --git a/cron.ts b/cron.ts index a6d9fea..4011721 100644 --- a/cron.ts +++ b/cron.ts @@ -96,9 +96,7 @@ export const validate = (schedule: string, date: Date = new Date()) => { ); } - const didMatch = Object.values(timeObj).every( - (assertion: boolean) => assertion === true, - ); + const didMatch = Object.values(timeObj).every(Boolean); return { didMatch, entries: timeObj, @@ -118,6 +116,7 @@ const runScheduler = () => { schedulerTimeIntervalID = setInterval(() => { if (shouldStopRunningScheduler) { clearInterval(schedulerTimeIntervalID); + return; } executeJobs(); }, 1000);