https://github.com/jtpio/murmurhash2
MurmurHash2 32-bit implemented in TypeScript
https://github.com/jtpio/murmurhash2
Last synced: about 1 year ago
JSON representation
MurmurHash2 32-bit implemented in TypeScript
- Host: GitHub
- URL: https://github.com/jtpio/murmurhash2
- Owner: jtpio
- License: bsd-3-clause
- Created: 2020-10-08T20:37:30.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2020-10-10T19:43:48.000Z (almost 6 years ago)
- Last Synced: 2025-03-15T00:07:08.567Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://murmurhash2.now.sh
- Size: 289 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# murmurhash2
[](https://github.com/jtpio/murmurhash2/actions)
[](https://www.npmjs.com/package/murmurhash2)
MurmurHash2 x86 32-bit implemented in TypeScript, with support for Unicode characters.
## Install
```bash
npm install murmurhash2
```
## Usage
```typescript
import { murmur2 } from 'murmurhash2';
const hash = murmur2('Hi there 👋', 12345);
console.log(hash);
// 1907773090
```
## Try it online
➡️ [**murmurhash2.now.sh**](http://murmurhash2.now.sh)
[](http://murmurhash2.now.sh)
## Development
Install nodejs and yarn, then:
```bash
yarn
yarn run build
```
## Tests
The repository contains a couple of sanity tests.
To run the tests:
```bash
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
- [MurmurHash2 by Austin Appleby](https://github.com/aappleby/smhasher/blob/master/src/MurmurHash2.cpp)
- Inspired by: [https://github.com/garycourt/murmurhash-js](https://github.com/garycourt/murmurhash-js)
- [xtensor-stack/xtl implentation](https://github.com/xtensor-stack/xtl/blob/7d41f768787ee6405e3f1b1056e04f6fbd43f8cd/include/xtl/xhash.hpp#L47)