( allLogs: LogOption[], startIndex: number, count: number, )
| 5075 | * index where scanning stopped (for progressive loading to continue from). |
| 5076 | */ |
| 5077 | export async function enrichLogs( |
| 5078 | allLogs: LogOption[], |
| 5079 | startIndex: number, |
| 5080 | count: number, |
| 5081 | ): Promise<{ logs: LogOption[]; nextIndex: number }> { |
| 5082 | const result: LogOption[] = [] |
| 5083 | const readBuf = Buffer.alloc(LITE_READ_BUF_SIZE) |
| 5084 | let i = startIndex |
| 5085 | |
| 5086 | while (i < allLogs.length && result.length < count) { |
| 5087 | const log = allLogs[i]! |
| 5088 | i++ |
| 5089 | |
| 5090 | const enriched = await enrichLog(log, readBuf) |
| 5091 | if (enriched) { |
| 5092 | result.push(enriched) |
| 5093 | } |
| 5094 | } |
| 5095 | |
| 5096 | const scanned = i - startIndex |
| 5097 | const filtered = scanned - result.length |
| 5098 | if (filtered > 0) { |
| 5099 | logForDebugging( |
| 5100 | `/resume: enriched ${scanned} sessions, ${filtered} filtered out, ${result.length} visible (${allLogs.length - i} remaining on disk)`, |
| 5101 | ) |
| 5102 | } |
| 5103 | |
| 5104 | return { logs: result, nextIndex: i } |
| 5105 | } |
| 5106 |
no test coverage detected