( allLogs: LogOption[], startIndex: number, count: number, )
| 5345 | * index where scanning stopped (for progressive loading to continue from). |
| 5346 | */ |
| 5347 | export async function enrichLogs( |
| 5348 | allLogs: LogOption[], |
| 5349 | startIndex: number, |
| 5350 | count: number, |
| 5351 | ): Promise<{ logs: LogOption[]; nextIndex: number }> { |
| 5352 | const result: LogOption[] = [] |
| 5353 | const readBuf = Buffer.alloc(LITE_READ_BUF_SIZE) |
| 5354 | let i = startIndex |
| 5355 | |
| 5356 | while (i < allLogs.length && result.length < count) { |
| 5357 | const log = allLogs[i]! |
| 5358 | i++ |
| 5359 | |
| 5360 | const enriched = await enrichLog(log, readBuf) |
| 5361 | if (enriched) { |
| 5362 | result.push(enriched) |
| 5363 | } |
| 5364 | } |
| 5365 | |
| 5366 | const scanned = i - startIndex |
| 5367 | const filtered = scanned - result.length |
| 5368 | if (filtered > 0) { |
| 5369 | logForDebugging( |
| 5370 | `/resume: enriched ${scanned} sessions, ${filtered} filtered out, ${result.length} visible (${allLogs.length - i} remaining on disk)`, |
| 5371 | ) |
| 5372 | } |
| 5373 | |
| 5374 | return { logs: result, nextIndex: i } |
| 5375 | } |
no test coverage detected