UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

1 lines 1.3 kB
{"version":3,"file":"getPathHash.mjs","names":[],"sources":["../../../src/utils/getPathHash.ts"],"sourcesContent":["/**\n * Fast hashing using cyrb53 algorithm for small unique strings with low collisions risk\n */\nexport const getPathHash = (filePath: string) => {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n\n for (let i = 0; i < filePath.length; i++) {\n const ch = filePath.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 =\n Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^\n Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 =\n Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^\n Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n const hash53 = 4294967296 * (2097151 & h2) + (h1 >>> 0);\n\n // Returns a string ~11 characters long, e.g., \"_1x9z5k2m8p3\"\n return hash53.toString(36);\n};\n"],"mappings":";;;;AAGA,MAAa,eAAe,aAAqB;CAC/C,IAAI,KAAK;CACT,IAAI,KAAK;CAET,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,KAAK,SAAS,WAAW,CAAC;EAChC,KAAK,KAAK,KAAK,KAAK,IAAI,UAAU;EAClC,KAAK,KAAK,KAAK,KAAK,IAAI,UAAU;CACpC;CAEA,KACE,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU,IACtC,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CACxC,KACE,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU,IACtC,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAKxC,QAHe,cAAc,UAAU,OAAO,OAAO,IAGvC,SAAS,EAAE;AAC3B"}