Function
countOccurrences
(content: string, search: string)
Source from the content-addressed store, hash-verified
| 53 | } |
| 54 | |
| 55 | const countOccurrences = (content: string, search: string) => { |
| 56 | if (search === "") return content.length + 1 |
| 57 | let count = 0 |
| 58 | let offset = 0 |
| 59 | while ((offset = content.indexOf(search, offset)) !== -1) { |
| 60 | count++ |
| 61 | offset += search.length |
| 62 | } |
| 63 | return count |
| 64 | } |
| 65 | |
| 66 | const previewLines = (value: string, prefix: "+" | "-") => { |
| 67 | const lines = normalizeLineEndings(value).split("\n") |
Tested by
no test coverage detected