UNPKG

@lou.codes/cron

Version:

⏲️ Cron Quartz and Cron UNIX expression parser

16 lines (15 loc) 513 B
import { group, join, optional } from "functional-expression"; import { RANGE_EXPRESSION_SEPARATOR_TOKEN } from "./tokens.js"; /** * Regular expression to match values or ranges. * * @category Regular Expression * @example * ```typescript * valueOrRangeRegExp(13); // "13(?:-13)?" * ``` * @param value Value to match by itself or as a range. * @returns RegExp to match value or range. */ export const valueOrRangeRegExp = value => join(value, optional(group(RANGE_EXPRESSION_SEPARATOR_TOKEN, value)));