Function
countOccurrencesBefore
(content: string, matchText: string, currentOffset: number)
Source from the content-addressed store, hash-verified
| 126 | } |
| 127 | |
| 128 | function countOccurrencesBefore(content: string, matchText: string, currentOffset: number): number { |
| 129 | let count = 0 |
| 130 | let searchIndex = 0 |
| 131 | |
| 132 | while (searchIndex < currentOffset) { |
| 133 | const idx = content.indexOf(matchText, searchIndex) |
| 134 | if (idx === -1 || idx >= currentOffset) break |
| 135 | count++ |
| 136 | searchIndex = idx + 1 |
| 137 | } |
| 138 | |
| 139 | return count |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * 在单个页面的消息中搜索,返回按消息分组的结果 |
Tested by
no test coverage detected