1.0.28 ā€¢ Published 7 days ago

@lou.codes/cron v1.0.28

Weekly downloads
-
License
MIT
Repository
github
Last release
7 days ago

Coverage License NPM Version Open Issues Size

ā²ļø Cron Quartz and Cron UNIX expression parser.

Usage

šŸ“¦ Node

Install @lou.codes/cron as a dependency:

pnpm add @lou.codes/cron
# or
npm install @lou.codes/cron
# or
yarn add @lou.codes/cron

Import it and use it:

import { parseStringQuartz, parseCronQuartz } from "@lou.codes/cron";

const cron = parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10");
/*
	{
		seconds: { every: 3, start: { from: 1, to: 2 } },
		minutes: [{ from: 1, to: 2 }, 3, 4],
		hours: "*",
		dayOfMonth: { nearest: 2 },
		month: ["SEP", "OCT"],
		dayOfWeek: { last: 1 },
		year: { every: 10, start: "*" }
	}
*/

parseCronQuartz(cron); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"

šŸ¦• Deno

Import @lou.codes/cron using the npm: prefix, and use it directly:

import { parseStringQuartz, parseCronQuartz } from "npm:@lou.codes/cron";

const cron = parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10");
/*
	{
		seconds: { every: 3, start: { from: 1, to: 2 } },
		minutes: [{ from: 1, to: 2 }, 3, 4],
		hours: "*",
		dayOfMonth: { nearest: 2 },
		month: ["SEP", "OCT"],
		dayOfWeek: { last: 1 },
		year: { every: 10, start: "*" }
	}
*/

parseCronQuartz(cron); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"

šŸŒŽ Browser

Import @lou.codes/cron using esm.sh, and use it directly:

<script type="module">
	import {
		parseStringQuartz,
		parseCronQuartz,
	} from "https://esm.sh/@lou.codes/cron";

	const cron = parseStringQuartz("1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10");
	/*
		{
			seconds: { every: 3, start: { from: 1, to: 2 } },
			minutes: [{ from: 1, to: 2 }, 3, 4],
			hours: "*",
			dayOfMonth: { nearest: 2 },
			month: ["SEP", "OCT"],
			dayOfWeek: { last: 1 },
			year: { every: 10, start: "*" }
		}
	*/

	parseCronQuartz(cron); // "1-2/3 1-2,3,4 * 2W SEP,OCT 1L */10"
</script>

Useful links

To do

A big change is coming with stricter types and a better DX. Stay tuned.

1.0.28

7 days ago

1.0.27

8 days ago

1.0.26

11 days ago

1.0.25

24 days ago

1.0.24

25 days ago

1.0.23

26 days ago

1.0.22

1 month ago

1.0.20

1 month ago

1.0.19

1 month ago

1.0.18

1 month ago

1.0.17

1 month ago

1.0.16

1 month ago

1.0.15

1 month ago

1.0.14

2 months ago

1.0.13

2 months ago

1.0.12

4 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.2

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.1

6 months ago

1.0.0

6 months ago