( allLogs: LogOption[], startIndex: number, count: number, )
| 5188 | * index where scanning stopped (for progressive loading to continue from). |
| 5189 | */ |
| 5190 | export async function enrichLogs( |
| 5191 | allLogs: LogOption[], |
| 5192 | startIndex: number, |
| 5193 | count: number, |
| 5194 | ): Promise<{ logs: LogOption[]; nextIndex: number }> { |
| 5195 | const result: LogOption[] = [] |
| 5196 | const readBuf = Buffer.alloc(LITE_READ_BUF_SIZE) |
| 5197 | let i = startIndex |
| 5198 | |
| 5199 | while (i < allLogs.length && result.length < count) { |
| 5200 | const log = allLogs[i]! |
| 5201 | i++ |
| 5202 | |
| 5203 | const enriched = await enrichLog(log, readBuf) |
| 5204 | if (enriched) { |
| 5205 | result.push(enriched) |
| 5206 | } |
| 5207 | } |
| 5208 | |
| 5209 | const scanned = i - startIndex |
| 5210 | const filtered = scanned - result.length |
| 5211 | if (filtered > 0) { |
| 5212 | logForDebugging( |
| 5213 | `/resume: enriched ${scanned} sessions, ${filtered} filtered out, ${result.length} visible (${allLogs.length - i} remaining on disk)`, |
| 5214 | ) |
| 5215 | } |
| 5216 | |
| 5217 | return { logs: result, nextIndex: i } |
| 5218 | } |
no test coverage detected