Skip to content

jtpio/murmurhash2

Repository files navigation

murmurhash2

Github Actions Status npm

MurmurHash2 x86 32-bit implemented in TypeScript, with support for Unicode characters.

Install

npm install murmurhash2

Usage

import { murmur2 } from 'murmurhash2';

const hash = murmur2('Hi there 👋', 12345);
console.log(hash);
// 1907773090

Try it online

➡️ murmurhash2.now.sh

image

Development

Install nodejs and yarn, then:

yarn
yarn run build

Tests

The repository contains a couple of sanity tests.

To run the tests:

yarn run test

Notes

This implementation is largely inspired by the one from Gary Court: https://github.com/garycourt/murmurhash-js

It uses a TextEncoder to encode the input string as a Uint8Array buffer before performing the calculation.

References