MCPcopy Create free account
hub / github.com/CatMuse/HiNote / hashCode

Method hashCode

src/utils/IdGenerator.ts:56–67  ·  view source on GitHub ↗

* 简单的字符串哈希函数 * @param str 要哈希的字符串 * @returns 哈希值

(str: string)

Source from the content-addressed store, hash-verified

54 * @returns 哈希值
55 */
56 private static hashCode(str: string): number {
57 let hash = 0;
58 if (str.length === 0) return hash;
59
60 for (let i = 0; i < str.length; i++) {
61 const char = str.charCodeAt(i);
62 hash = ((hash << 5) - hash) + char;
63 hash = hash & hash; // 转换为32位整数
64 }
65
66 return hash;
67 }
68
69 /**
70 * 检查是否为有效的高亮ID格式

Callers 1

generateHighlightIdMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected