Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
⏳ Fantastic cron parser and constructor.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
JSR Score
100%
Published
2 months ago (0.3.3)
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)));