From adfb18546a328d9aedf0205bf9d9510dacf573c3 Mon Sep 17 00:00:00 2001 From: Rahul Baruri Date: Mon, 25 May 2020 12:18:39 +0200 Subject: [PATCH] Minor refactoring done and updated API doc --- README.md | 2 ++ cron.ts | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) 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);