2.1.1 • Published 4 months ago

cruxhash v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

CRUXHash

View on NPM License

A set of crucial hash functions for ECMAScript.

Installation

Use the npm package manager to install CRUXHash.

npm i cruxhash

Usage

CRUXHash provides a set of simple functions to create unsigned 32-bit integer hash codes for trivial ECMAScript values. See the example bellow:

import { hash, getSeed } from 'cruxhash';

console.log(hash('Smile, my dear!')); // returns 2890382619

console.log(hash(42)); // returns 1462734105

console.log(hash(42, getSeed('my seed'))); // returns 8142968

console.log(hash({ a: 10, b: 10 })); // returns 3685477545

console.log(hash([1, 2, 3])); // returns 2610324319

console.log(hash('コンニチハ, Hello world, Καλημέρα κόσμε 😀')); // returns 1898574527

Most of times, the function hash is sufficient for making the hash codes. If you need some tampering, pass a number to the seed parameter to start the hash algorithm. You can use the the getSeed function to generate some seeds from strings. Other functions are available, see the Wiki's Page for the complete API.

CRUXHash uses Murmur3 as the hashing algorithm in most of cases, the exception is when hashing 32bit integers, where it uses Thomas Wang's shift and multiplication algorithm.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

2.1.1

4 months ago

2.0.3

6 months ago

2.0.2

6 months ago

2.1.0

6 months ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago