Extract library from plugin

This commit is contained in:
Andras Schmelczer 2025-02-18 22:32:41 +00:00
parent 8374c971ee
commit ae3acb9e1e
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
37 changed files with 61 additions and 77 deletions

View file

@ -0,0 +1,12 @@
// https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
export function hash(content: Uint8Array): string {
let result = 0;
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < content.length; i++) {
result = (result << 5) - result + content[i];
result |= 0; // Convert to 32bit integer
}
return Math.abs(result).toString(16);
}
export const EMPTY_HASH = hash(new Uint8Array(0));