Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.2.2 #6

Merged
merged 6 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```
26 changes: 26 additions & 0 deletions src/cron.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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", () => {
Expand All @@ -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 * * *");
Expand Down