/** * croniq — a tiny, zero-dependency cron expression toolkit. * * Parse standard 5-field (and 6-field "with seconds") cron expressions, then * compute the next/previous run times and a human-readable description. The * time arithmetic uses field-jumping (not minute-by-minute scanning), so even * sparse schedules resolve quickly. */ interface CronOptions { /** Interpret and emit times in UTC instead of local time. Default: `false`. */ utc?: boolean; } /** A parsed cron expression. Create one with {@link parse} (or `new Cron(...)`). */ declare class Cron { readonly expression: string; readonly hasSeconds: boolean; readonly seconds: number[]; readonly minutes: number[]; readonly hours: number[]; readonly daysOfMonth: number[]; readonly months: number[]; readonly daysOfWeek: number[]; /** Raw field tokens (after macro expansion), for description. */ readonly raw: { seconds?: string; minute: string; hour: string; dayOfMonth: string; month: string; dayOfWeek: string; }; private readonly domRestricted; private readonly dowRestricted; private readonly utc; constructor(expression: string, options?: CronOptions); private acc; private dayMatches; /** Does `date` satisfy this expression (to minute, or second, precision)? */ matches(date?: Date): boolean; /** The next run time strictly after `from` (default: now). Throws if none within ~bounds. */ next(from?: Date): Date; /** The previous run time strictly before `from` (default: now). */ prev(from?: Date): Date; /** The next `count` run times after `from`. */ nextN(count: number, from?: Date): Date[]; /** The previous `count` run times before `from`. */ prevN(count: number, from?: Date): Date[]; private daysInMonth; private step; /** A human-readable English description, e.g. "At 09:00, Monday through Friday". */ describe(): string; } /** * Parse a cron expression into a {@link Cron} you can query. * * ```ts * const cron = parse("0 9 * * 1-5"); // 09:00 on weekdays * cron.next(); // → next weekday 09:00 * cron.describe(); // "At 09:00, Monday through Friday" * ``` * * Supports 5 fields (min hour dom month dow) or 6 (with a leading seconds * field), ranges (`1-5`), lists (`1,3,5`), steps (`*​/15`), names (`JAN`, * `MON`), `?`, and macros (`@daily`, `@hourly`, …). */ declare function parse(expression: string, options?: CronOptions): Cron; /** Returns `true` if `expression` is a valid cron expression. */ declare function isValid(expression: string, options?: CronOptions): boolean; export { Cron, type CronOptions, isValid, parse };