Skip to content

Initial implementation - #1

Merged
mjradwin merged 3 commits into
mainfrom
claude/murmurhash-package-migration-o0m027
Jul 29, 2026
Merged

mjradwin merged 3 commits into
mainfrom
claude/murmurhash-package-migration-o0m027

Conversation

@mjradwin

Copy link
Copy Markdown
Member

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.

claude added 2 commits July 29, 2026 21:40
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
@github-advanced-security

Copy link
Copy Markdown
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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Comment thread .github/workflows/node.js.yml Fixed
…ntain permissions'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@mjradwin
mjradwin merged commit cad325f into main Jul 29, 2026
7 checks passed
@mjradwin
mjradwin deleted the claude/murmurhash-package-migration-o0m027 branch July 29, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants