diff --git a/package.json b/package.json index bf9eb6d..75d0bcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cron-toolkit-ts", - "version": "0.2.0", + "version": "0.2.2", "description": "Type-safe Toolkit to get cron expressions for JavaScript and TypeScript", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/readme.md b/readme.md index 9ecc7f6..4ef3938 100644 --- a/readme.md +++ b/readme.md @@ -60,4 +60,19 @@ const atMorning = Cron.atMorning(); // 0 9 * * * every day at 9:00 const atEvening = Cron.atEvening(); // 0 18 * * * every day at 18:00 const atAfternoon = Cron.atAfternoon(); // 0 15 * * * every day at 15:00 const atStartOfTheDay = Cron.atStartOfTheDay(); // 0 0 * * * every day at 00:00 +``` + +### Months +```ts +const everyMonth = Cron.everyMonth(); // 0 0 1 * * every month at 1st day at 00:00 +``` + +## Non-standard cron expressions + +### Seconds + +```typescript +const every5Seconds = cron.useNonStandard().everyCustomSecond(5); +const every10Seconds = cron.useNonStandard().every15Seconds(); +const every45Seconds = cron.useNonStandard().every45Seconds(); ``` \ No newline at end of file diff --git a/src/cron.test.ts b/src/cron.test.ts index ac52952..d643abd 100644 --- a/src/cron.test.ts +++ b/src/cron.test.ts @@ -43,6 +43,10 @@ describe("Standard Cron Expressions", () => { expect(cron.atMinute(30)).toEqual("30 * * * *"); expect(cron.atMinute(45)).toEqual("45 * * * *"); }); + + it("gets between minutes expressions", () => { + expect(cron.betweenMinutes(0, 59)).toEqual("0-59 * * * *"); + }) }); describe("Hours", () => { @@ -60,6 +64,10 @@ describe("Standard Cron Expressions", () => { // alternative expect(cron.everyCustomHour(3)).toEqual("0 */3 * * *"); expect(cron.everyCustomHour(4)).toEqual("0 */4 * * *"); + + it("gets between hours expressions", () => { + expect(cron.betweenHours(0, 23)).toEqual("0 0-23 * * *"); + }) }); describe("Days", () => { @@ -84,8 +92,26 @@ describe("Standard Cron Expressions", () => { it("gets every week day expressions at 00:00", () => { expect(cron.everyWeekDay()).toEqual("0 0 * * 1-5"); }); + + it("gets at day expressions", () => { + expect(cron.atDay(1)).toEqual("0 0 1 * *"); + }) + + it("gets between days expressions", () => { + expect(cron.betweenDays(0, 31)).toEqual("0 0 0-31 * *"); + }) }); + describe('Month', () => { + it('gets at month expressions', () => { + expect(cron.atMonth(0)).toEqual("0 0 1 0 *"); + }) + + it('gets between months expressions', () => { + expect(cron.betweenMonths(0, 11)).toEqual("0 0 1 0-11 *"); + }) + }) + describe("Through The Day", () => { it("gets 12:00 AM", () => { expect(cron.atStartOfTheDay()).toEqual("0 0 * * *");