summary.ts
554 bytes
| 1 | import type { Segment } from '../../shared/types' |
|---|---|
| 2 | |
| 3 | export const RECENT_SEGMENT_WINDOW = 40 |
| 4 | |
| 5 | export interface TranscriptWindow { |
| 6 | recentSegments: Segment[] |
| 7 | olderSegments: Segment[] |
| 8 | } |
| 9 | |
| 10 | export function splitTranscriptWindow(segments: Segment[]): TranscriptWindow { |
| 11 | if (segments.length <= RECENT_SEGMENT_WINDOW) { |
| 12 | return { recentSegments: segments, olderSegments: [] } |
| 13 | } |
| 14 | const splitIndex = segments.length - RECENT_SEGMENT_WINDOW |
| 15 | return { |
| 16 | recentSegments: segments.slice(splitIndex), |
| 17 | olderSegments: segments.slice(0, splitIndex), |
| 18 | } |
| 19 | } |
| 20 | |