UNPKG

@lou.codes/cron

Version:

⏲️ Cron Quartz and Cron UNIX expression parser

18 lines (17 loc) 544 B
import { head } from "@lou.codes/iterables"; import { nextDates } from "./nextDates.js"; /** * Get next ISO date string for the given date and the given cron expression. * * @category Util * @example * ```typescript * nextDate(new Date("1989-10-13T10:15:00.000"))("* * * * *"); // Date("1989-10-13T10:16:00.000") * ``` * @param date Base date to get the next date from. * @returns Curried function with date set. */ export const nextDate = date => { const nextDatesFor = nextDates(date); return cron => head(nextDatesFor(cron)); };