(cron: CronExpression, after: Date)
| 113 | * expression can't lock the scheduler. |
| 114 | */ |
| 115 | export function nextAfter(cron: CronExpression, after: Date): Date | null { |
| 116 | const limit = 60 * 24 * 366 * 2; |
| 117 | const probe = new Date(after.getTime()); |
| 118 | // Round up to next minute boundary so we don't yield `after` itself. |
| 119 | probe.setSeconds(0, 0); |
| 120 | probe.setMinutes(probe.getMinutes() + 1); |
| 121 | for (let i = 0; i < limit; i++) { |
| 122 | if (matches(cron, probe)) return probe; |
| 123 | probe.setMinutes(probe.getMinutes() + 1); |
| 124 | } |
| 125 | return null; |
| 126 | } |
no test coverage detected