Reference
CronParser
The class behind Cron's static methods. It holds one expression, which is convenient when you want to ask several questions about the same schedule.
On this page
import { CronParser } from "cronbake";
const parser = new CronParser("0 30 9 * * 1-5");
parser.parse(); // { second: [0], minute: [30], hour: [9], ... }
parser.getNext(); // the next match
parser.getPrevious(); // the last matchThe constructor doesn’t validate anything. An invalid expression throws when you first call a method.
In most code the static methods on Cron read better, and they do the same thing.
Methods
parse()
parse(): CronTimeExpands the expression or preset into the values each field matches. Throws if it’s invalid.
getNext()
getNext(from?: Date): DateThe first match after from, which defaults to now. Throws if the expression is invalid, from is an invalid date, or nothing matches within 400 years.
getPrevious()
getPrevious(from?: Date): DateThe last match before from, which defaults to now. Throws in the same cases as getNext().