UNPKG

@lou.codes/cron

Version:

⏲️ Cron Quartz and Cron UNIX expression parser

17 lines (16 loc) 522 B
import { parseDecimal } from "@lou.codes/parsers"; import { rangeStringMatch } from "./rangeStringMatch.js"; import { RANGE_EXPRESSION_SEPARATOR_TOKEN } from "./tokens.js"; /** * Predicate checking if given value is a cron string range * ({@link RangeString}). * * @category Predicate * @see {@link RangeString} * @see {@link rangeStringMatch} */ export const isRangeString = value => rangeStringMatch(value) && (([from, to]) => from <= to)( value.split(RANGE_EXPRESSION_SEPARATOR_TOKEN).map(parseDecimal), );