#709 Add extra type safety for token counting

This commit is contained in:
Cohee
2023-07-14 15:33:55 +03:00
parent 5812e34dcb
commit 8987534403
2 changed files with 8 additions and 0 deletions

View File

@@ -86,6 +86,10 @@ export async function parseJsonFile(file) {
}
export function getStringHash(str, seed = 0) {
if (typeof str !== 'string') {
return 0;
}
let h1 = 0xdeadbeef ^ seed,
h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {