A solid-fuel kitchen's last exhaust inspection was January 31, 2024. Its next three planning dates are February 29, March 31, and April 30. Calling setUTCMonth() to move January 31 into February gives March 2. Reusing February 29 as the anchor for the next projected visit gives March 29. Either arithmetic shortcut changes a deadline.
| Step | Correct projected date | Reason |
|---|---|---|
| Last recorded inspection | 2024-01-31 | Start at the completion date |
| Add one month | 2024-02-29 | February ends on day 29 |
| Add two months | 2024-03-31 | March can use day 31 |
| Add three months | 2024-04-30 | April ends on day 30 |
Keep two clocks per kitchen
The exhaust track models NFPA 96 Table 12.4 inspection intervals for grease buildup. Solid fuel uses one month, high volume uses three, moderate volume uses six, and low volume uses twelve. The high-volume class includes 24-hour operations, charbroiling, and wok cooking. Low-volume examples include churches and seasonal operations. The example uses a separate six-month professional inspection/service cadence for the UL 300 suppression system. A visit on one track updates that track's history.
The scheduler evaluates readiness on an explicit calendar day. The due-soon window includes today and its final day. It flags empty records as missing. When the route calendar opens on February 1 and an exhaust inspection was due January 31, the calendar queues the visit for February 1 and keeps January 31 as the missed deadline. Later projections assume the catch-up happens on February 1. A missing record gets one immediate action to establish the baseline.
At a real site, confirm the adopted code, scope, and dates with the authority having jurisdiction. Cleaning decisions depend on inspection findings. The benchmark exercises schedule arithmetic and record handling.
Benchmark a route book
Run this from the repository root on Node.js 20 or later. It times route generation for 40 and 400 synthetic kitchens across eight routes. Fixtures include month-end completions, overdue work, missing suppression records, and all four cooking classes. Assertions run before timing, and each row reports the median of five warmed samples along with the number of generated visits. MIT source repository
node --input-type=module <<'JS' import assert from 'node:assert/strict'; import { performance } from 'node:perf_hooks'; import { addCalendarMonths, generateRouteSchedule, summarizeReadiness } from './src/index.js'; const rollover = new Date('2024-01-31T00:00:00Z'); rollover.setUTCMonth(1); assert.equal(rollover.toISOString().slice(0, 10), '2024-03-02'); assert.equal(addCalendarMonths('2024-01-31', 1), '2024-02-29'); assert.equal(addCalendarMonths('2024-01-31', 12), '2025-01-31'); const anchor = { id: 'woodfire', route: 'Central', cookingVolume: 'solid-fuel', lastExhaustInspection: '2024-01-31', lastSuppressionInspection: '2024-01-31', }; const options = { asOf: '2024-02-01', through: '2024-04-30', dueSoonDays: 28 }; assert.deepEqual(generateRouteSchedule([anchor], options).map((group) => group.date), ['2024-02-29', '2024-03-31', '2024-04-30']); assert.equal(summarizeReadiness([anchor], options).trackCounts['due-soon'], 1); const classes = ['solid-fuel', 'high-volume', 'moderate-volume', 'low-volume']; const history = ['2024-01-31', '2023-12-31', '2023-08-31', '2023-01-31']; const counts = []; for (const [size, batches] of [[40, 200], [400, 50]]) { const kitchens = Array.from({ length: size }, (_, i) => ({ id: `K${i}`, route: `Route ${i % 8 + 1}`, cookingVolume: classes[i % classes.length], lastExhaustInspection: history[i % history.length], lastSuppressionInspection: i % 10 === 0 ? null : '2023-08-31', })); const report = summarizeReadiness(kitchens, options); const expected = generateRouteSchedule(kitchens, options).flatMap(({ visits }) => visits); assert.equal(report.trackCounts.missing, size / 10); assert.equal(expected.filter(({ status }) => status === 'missing').length, size / 10); assert.equal(expected.filter(({ status }) => status === 'overdue').length, size / 4); assert.ok(expected.some(({ projected }) => projected)); for (let i = 0; i < 40; i++) generateRouteSchedule(kitchens, options); const samples = []; for (let sample = 0; sample < 5; sample++) { let checksum = 0; const start = performance.now(); for (let run = 0; run < batches; run++) { const groups = generateRouteSchedule(kitchens, options); for (const group of groups) checksum += group.visits.length; } samples.push((performance.now() - start) / batches); assert.equal(checksum, batches * expected.length); } samples.sort((a, b) => a - b); counts.push({ kitchens: size, visits: expected.length, medianMsPerRun: samples[2].toFixed(3) }); } console.log(process.version, process.platform, process.arch); console.table(counts); JS One run on Node.js 24.14.1 for macOS arm64 produced these medians per schedule.
| Kitchens | Visits | Median ms |
|---|---|---|
| 40 | 100 | 0.201 |
| 400 | 1,000 | 2.081 |
The timing includes input validation, recurrence generation, sorting, grouping, and the visit checksum. It excludes DOM rendering and fixture construction. When comparing runs, hold both the date range and fixture constant. A longer horizon changes the number of projected visits, even with the same location count.
Try the same month-end example with two kitchens and a missing suppression record in the interactive GitHub Pages demo. See HoodCert for hood inspection workflows and BEOPack for banquet event order workflows.
