Initial implementation - #1
Merged
Merged
Conversation
Pure-JS implementation of MurmurHash3 x86 (32-bit and 128-bit), byte-for-byte compatible with the native murmurhash3 npm package, so it is a drop-in replacement that preserves previously computed hash values. No node-gyp / C++ build and no allowScripts install step. Exports the synchronous interface used across the hebcal repos: - murmur32Sync / murmur32HexSync - murmur128Sync / murmur128HexSync Inputs are hashed as UTF-8, matching the native binding (and unlike murmurhash3js, which hashes JS char codes and diverges on non-ASCII). Compatibility is locked by test/fixtures.json: 866 reference vectors captured directly from the native implementation (all tail lengths, multi-block inputs, ASCII/Hebrew/emoji/accented strings, multiple seeds). The vitest suite asserts every vector reproduces, 877 tests passing. Tooling mirrors @hebcal/icalendar: TypeScript, oxlint, prettier, vitest, and CI across Node 22/24/26 plus CodeQL and OIDC trusted-publish workflows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QJJ1CLi9PzXD9QgwYD5xAP
toBytes() used new TextEncoder().encode(), which is several times slower than Buffer.from(key, 'utf8') for the short strings this package hashes — enough to make the pure-JS package slower than the native murmurhash3 it replaces. Select the encoder once at module load: Buffer.from when available (Node, where all consumers run), falling back to TextEncoder in other runtimes so the package stays portable. Both produce identical UTF-8 for well-formed strings, and the manual byte indexing in the hash loops works on either a Buffer or a Uint8Array, so output is unchanged — all 877 fixture vectors still match the native lib. This restores parity with (and for ASCII, a slight edge over) the native implementation, instead of a ~2.5x regression. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QJJ1CLi9PzXD9QgwYD5xAP
Contributor
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
…ntain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure-JS implementation of MurmurHash3 x86 (32-bit and 128-bit), byte-for-byte compatible with the native murmurhash3 npm package, so it is a drop-in replacement that preserves previously computed hash values. No node-gyp / C++ build and no allowScripts install step.
Exports the synchronous interface used across the hebcal repos:
Inputs are hashed as UTF-8, matching the native binding (and unlike murmurhash3js, which hashes JS char codes and diverges on non-ASCII).
Compatibility is locked by test/fixtures.json: 866 reference vectors captured directly from the native implementation (all tail lengths, multi-block inputs, ASCII/Hebrew/emoji/accented strings, multiple seeds). The vitest suite asserts every vector reproduces, 877 tests passing.
Tooling mirrors @hebcal/icalendar: TypeScript, oxlint, prettier, vitest, and CI across Node 22/24/26 plus CodeQL and OIDC trusted-publish workflows.