详细说明: - 添加了V2版本的工作流页面和结果页面 - 更新了Serena记忆文件 - 添加了详细实施计划文档 - 优化了Vite配置 - 更新了项目文档CLAUDE.md - 构建了演示系统的dist版本 - 包含了exhibition-demo的完整依赖
37 lines
823 B
JavaScript
37 lines
823 B
JavaScript
/**
|
|
* Get the count of the longest repeating streak of `substring` in `value`.
|
|
*
|
|
* @param {string} value
|
|
* Content to search in.
|
|
* @param {string} substring
|
|
* Substring to look for, typically one character.
|
|
* @returns {number}
|
|
* Count of most frequent adjacent `substring`s in `value`.
|
|
*/
|
|
export function longestStreak(value, substring) {
|
|
const source = String(value)
|
|
let index = source.indexOf(substring)
|
|
let expected = index
|
|
let count = 0
|
|
let max = 0
|
|
|
|
if (typeof substring !== 'string') {
|
|
throw new TypeError('Expected substring')
|
|
}
|
|
|
|
while (index !== -1) {
|
|
if (index === expected) {
|
|
if (++count > max) {
|
|
max = count
|
|
}
|
|
} else {
|
|
count = 1
|
|
}
|
|
|
|
expected = index + substring.length
|
|
index = source.indexOf(substring, expected)
|
|
}
|
|
|
|
return max
|
|
}
|