Skip to main content

@coven/cron@0.3.3
Built and signed on GitHub Actions

⏳ Fantastic cron parser and constructor.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 months ago (0.3.3)
Package root>fieldRegExp.ts
import { captureNamed, escape, or } from "jsr:@coven/expression@^0.3.3"; import { ALL_TOKEN } from "./tokens.ts"; import { valueRangeOrListRegExp } from "./valueRangeOrListRegExp.ts"; /** * Regular expression to match a cron expression field. * * @example * ```typescript * fieldRegExp("example", "13"); // "(?<example>\\*|(?:13(?:-13)?|(?:(?:13(?:-13)?,)+13(?:-13)?)))" * ``` * @param name Named group name. * @param value Possible values the expression can have. * @returns Named group capturing the given value by itself, in a list or range. */ export const fieldRegExp = <Name extends string, Value extends string>( name: Name, value: Value, ): `(?<${Name}>\\*|(?:${Value}(?:-${Value})?|(?:(?:${Value}(?:-${Value})?,)+${Value}(?:-${Value})?)))` => captureNamed(name)(or(escape(ALL_TOKEN), valueRangeOrListRegExp(value)));