(text: string)
| 91 | } |
| 92 | |
| 93 | async chunk(text: string): Promise<Chunk[]> { |
| 94 | if (!text?.trim()) { |
| 95 | return [] |
| 96 | } |
| 97 | |
| 98 | const cleaned = cleanText(text) |
| 99 | let chunks = this.splitRecursively(cleaned) |
| 100 | |
| 101 | if (this.chunkOverlap > 0) { |
| 102 | const overlapChars = tokensToChars(this.chunkOverlap) |
| 103 | chunks = addOverlap(chunks, overlapChars) |
| 104 | } |
| 105 | |
| 106 | return buildChunks(chunks, this.chunkOverlap) |
| 107 | } |
| 108 | } |
no test coverage detected