* WIP * Add debug * Dedupe inserts * Add deterministic ordering * Fix whitespaces * Update insta * Add integration test script * Rename * Add test * Working for non-deletes * omg it mostly works for deletes * Isdeleted fix * remove created dates * update api * Take document id * No max attempt * works * Use string uuids * . * working!!!! (hopefully) * Improve bundling * Add module * lint * . * lint * Fix CI * use toolchain * clean up * Add useSlowFileEvents * Delete fuzz * Fix CI * use docker * fix script * clean up * Clean up * change node version * Build docker image on every commit * fix ci * 1 db per vault * Add scritps folder * Bump versions * Lint * . * Fix tests for real * Style * . * try * Consistent ordering * Fix tests * hmm * . * Clean up diff * Fixes * . * Fix version bump * . * . * .
12 lines
468 B
TypeScript
12 lines
468 B
TypeScript
// 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).padStart(8, "0");
|
|
}
|
|
|
|
export const EMPTY_HASH = hash(new Uint8Array(0));
|