hashをパスと行数から決定

This commit is contained in:
tai-cha
2025-02-21 22:29:42 +09:00
parent dc9472771b
commit 1e80ee5bd0
7 changed files with 95 additions and 17 deletions

View File

@@ -35,7 +35,7 @@ const externalPackages = [
},
];
const hash = (str: string, seed = 0): number => {
export const hash = (str: string, seed = 0): number => {
let h1 = 0xdeadbeef ^ seed,
h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {
@@ -50,9 +50,9 @@ const hash = (str: string, seed = 0): number => {
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
};
const BASE62_DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
export const BASE62_DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
function toBase62(n: number): string {
export function toBase62(n: number): string {
if (n === 0) {
return '0';
}