rapidhash-js 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +62 -5
- package/lib/index.d.mts +63 -0
- package/lib/index.d.ts +63 -0
- package/lib/index.js +370 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +335 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +21 -5
- package/build/src/index.d.ts +0 -1
- package/build/src/index.js +0 -18
- package/build/src/rapidhash.d.ts +0 -33
- package/build/src/rapidhash.js +0 -198
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.0] - 2025-05-18
|
|
4
|
+
|
|
5
|
+
- Implement [rapidhash v2](https://github.com/Nicoshev/rapidhash/pull/16).
|
|
6
|
+
|
|
7
|
+
## [1.0.4] - 2024-10-07
|
|
8
|
+
|
|
9
|
+
- Support both ESM and CommonJS modules.
|
|
10
|
+
|
|
3
11
|
## [1.0.3] - 2024-09-24
|
|
4
12
|
|
|
5
13
|
- Some performance improvements.
|
package/README.md
CHANGED
|
@@ -18,25 +18,82 @@ npm install rapidhash-js
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
// The functions rapidhash, rapidhash_fast, and rapidhash_protected currently implement the v2 algorithm.
|
|
23
|
+
rapidhash,
|
|
24
|
+
rapidhash_fast,
|
|
25
|
+
rapidhash_protected,
|
|
26
|
+
// To use the old v1 algorithm, import rapidhash_v1 (or rapidhash_v1_fast, rapidhash_v1_protected) instead.
|
|
27
|
+
rapidhash_v1,
|
|
28
|
+
} from 'rapidhash-js';
|
|
22
29
|
|
|
23
30
|
// rapidhash() returns a 64-bit hash value represented as bigint.
|
|
24
|
-
console.log(rapidhash('hello world')); // Output:
|
|
31
|
+
console.log(rapidhash('hello world')); // Output: 1722744455612372674n
|
|
25
32
|
|
|
26
33
|
// You can specify a 64-bit seed value with the 'seed' option.
|
|
27
|
-
console.log(rapidhash('hello world', {seed: 0x0123_4567_89AB_CDEFn})); // Output:
|
|
34
|
+
console.log(rapidhash('hello world', {seed: 0x0123_4567_89AB_CDEFn})); // Output: 13409940373860458135n
|
|
28
35
|
|
|
29
36
|
// You can specify the behavior of the rapid_mum() function
|
|
30
37
|
// with the rapidMumBehaviour option (default is 'fast').
|
|
31
|
-
console.log(rapidhash('hello world', {rapidMumBehaviour: 'protected'})); // Output:
|
|
38
|
+
console.log(rapidhash('hello world', {rapidMumBehaviour: 'protected'})); // Output: 12365338091610779222n
|
|
32
39
|
|
|
33
40
|
// Instead of specifying the rapidMumBehaviour option,
|
|
34
41
|
// you can call rapidhash_fast() or rapidhash_protected().
|
|
35
42
|
console.log(rapidhash_protected('hello world'));
|
|
36
43
|
```
|
|
37
44
|
|
|
45
|
+
## Benchmark
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
[Benchmark Environment]
|
|
49
|
+
Node.js: v22.15.1
|
|
50
|
+
CPU: Apple M3 Max (16 cores, 2400 MHz)
|
|
51
|
+
|
|
52
|
+
[1-4 bytes]
|
|
53
|
+
rapidhash_v1_fast : 6,158,460.80 ops/s (162.38 ns/iter)
|
|
54
|
+
rapidhash_v1_protected : 5,238,665.86 ops/s (190.89 ns/iter)
|
|
55
|
+
rapidhash_v2_fast : 6,652,432.34 ops/s (150.32 ns/iter)
|
|
56
|
+
rapidhash_v2_protected : 5,426,323.09 ops/s (184.29 ns/iter)
|
|
57
|
+
|
|
58
|
+
[1-8 bytes]
|
|
59
|
+
rapidhash_v1_fast : 5,734,137.37 ops/s (174.39 ns/iter)
|
|
60
|
+
rapidhash_v1_protected : 5,110,619.92 ops/s (195.67 ns/iter)
|
|
61
|
+
rapidhash_v2_fast : 5,928,919.83 ops/s (168.66 ns/iter)
|
|
62
|
+
rapidhash_v2_protected : 5,263,867.11 ops/s (189.97 ns/iter)
|
|
63
|
+
|
|
64
|
+
[1-16 bytes]
|
|
65
|
+
rapidhash_v1_fast : 5,655,101.18 ops/s (176.83 ns/iter)
|
|
66
|
+
rapidhash_v1_protected : 5,096,905.96 ops/s (196.20 ns/iter)
|
|
67
|
+
rapidhash_v2_fast : 5,861,882.39 ops/s (170.59 ns/iter)
|
|
68
|
+
rapidhash_v2_protected : 5,210,155.86 ops/s (191.93 ns/iter)
|
|
69
|
+
|
|
70
|
+
[17-56 bytes]
|
|
71
|
+
rapidhash_v1_fast : 3,769,517.21 ops/s (265.29 ns/iter)
|
|
72
|
+
rapidhash_v1_protected : 3,342,290.50 ops/s (299.20 ns/iter)
|
|
73
|
+
rapidhash_v2_fast : 3,982,046.12 ops/s (251.13 ns/iter)
|
|
74
|
+
rapidhash_v2_protected : 3,515,249.93 ops/s (284.47 ns/iter)
|
|
75
|
+
|
|
76
|
+
[57-128 bytes]
|
|
77
|
+
rapidhash_v1_fast : 2,260,312.89 ops/s (442.42 ns/iter)
|
|
78
|
+
rapidhash_v1_protected : 2,048,074.92 ops/s (488.26 ns/iter)
|
|
79
|
+
rapidhash_v2_fast : 2,161,841.53 ops/s (462.57 ns/iter)
|
|
80
|
+
rapidhash_v2_protected : 2,005,979.52 ops/s (498.51 ns/iter)
|
|
81
|
+
|
|
82
|
+
[129-256 bytes]
|
|
83
|
+
rapidhash_v1_fast : 1,291,980.54 ops/s (774.01 ns/iter)
|
|
84
|
+
rapidhash_v1_protected : 1,201,241.40 ops/s (832.47 ns/iter)
|
|
85
|
+
rapidhash_v2_fast : 1,274,486.99 ops/s (784.63 ns/iter)
|
|
86
|
+
rapidhash_v2_protected : 1,200,791.35 ops/s (832.78 ns/iter)
|
|
87
|
+
|
|
88
|
+
[1M bytes]
|
|
89
|
+
rapidhash_v1_fast : 308.34 ops/s (3.24 ms/iter)
|
|
90
|
+
rapidhash_v1_protected : 291.73 ops/s (3.43 ms/iter)
|
|
91
|
+
rapidhash_v2_fast : 309.57 ops/s (3.23 ms/iter)
|
|
92
|
+
rapidhash_v2_protected : 291.12 ops/s (3.43 ms/iter)
|
|
93
|
+
```
|
|
94
|
+
|
|
38
95
|
## License
|
|
39
96
|
|
|
40
97
|
MIT License
|
|
41
98
|
|
|
42
|
-
Copyright (c)
|
|
99
|
+
Copyright (c) 2025 KOMIYA Atsushi.
|
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
type RapidMumBehaviour = 'fast' | 'protected';
|
|
2
|
+
interface RapidhashOptions {
|
|
3
|
+
seed: bigint;
|
|
4
|
+
rapidMumBehaviour: RapidMumBehaviour;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calculate a 64-bit hash value of the given message.
|
|
9
|
+
*
|
|
10
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
11
|
+
* @param options Options for modifying the hash calculation.
|
|
12
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
13
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
14
|
+
*/
|
|
15
|
+
declare function rapidhash_v1(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate a 64-bit hash value of the given message.
|
|
18
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
19
|
+
*
|
|
20
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
21
|
+
* @param options Options for modifying the hash calculation.
|
|
22
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
23
|
+
*/
|
|
24
|
+
declare function rapidhash_v1_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
25
|
+
/**
|
|
26
|
+
* Calculate a 64-bit hash value of the given message.
|
|
27
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
28
|
+
*
|
|
29
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
30
|
+
* @param options Options for modifying the hash calculation.
|
|
31
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
32
|
+
*/
|
|
33
|
+
declare function rapidhash_v1_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Calculate a 64-bit hash value of the given message.
|
|
37
|
+
*
|
|
38
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
39
|
+
* @param options Options for modifying the hash calculation.
|
|
40
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
41
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
42
|
+
*/
|
|
43
|
+
declare function rapidhash_v2(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate a 64-bit hash value of the given message.
|
|
46
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
47
|
+
*
|
|
48
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
49
|
+
* @param options Options for modifying the hash calculation.
|
|
50
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
51
|
+
*/
|
|
52
|
+
declare function rapidhash_v2_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
53
|
+
/**
|
|
54
|
+
* Calculate a 64-bit hash value of the given message.
|
|
55
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
56
|
+
*
|
|
57
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
58
|
+
* @param options Options for modifying the hash calculation.
|
|
59
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
60
|
+
*/
|
|
61
|
+
declare function rapidhash_v2_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
62
|
+
|
|
63
|
+
export { rapidhash_v2 as rapidhash, rapidhash_v2_fast as rapidhash_fast, rapidhash_v2_protected as rapidhash_protected, rapidhash_v1, rapidhash_v1_fast, rapidhash_v1_protected, rapidhash_v2, rapidhash_v2_fast, rapidhash_v2_protected };
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
type RapidMumBehaviour = 'fast' | 'protected';
|
|
2
|
+
interface RapidhashOptions {
|
|
3
|
+
seed: bigint;
|
|
4
|
+
rapidMumBehaviour: RapidMumBehaviour;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Calculate a 64-bit hash value of the given message.
|
|
9
|
+
*
|
|
10
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
11
|
+
* @param options Options for modifying the hash calculation.
|
|
12
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
13
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
14
|
+
*/
|
|
15
|
+
declare function rapidhash_v1(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate a 64-bit hash value of the given message.
|
|
18
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
19
|
+
*
|
|
20
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
21
|
+
* @param options Options for modifying the hash calculation.
|
|
22
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
23
|
+
*/
|
|
24
|
+
declare function rapidhash_v1_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
25
|
+
/**
|
|
26
|
+
* Calculate a 64-bit hash value of the given message.
|
|
27
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
28
|
+
*
|
|
29
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
30
|
+
* @param options Options for modifying the hash calculation.
|
|
31
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
32
|
+
*/
|
|
33
|
+
declare function rapidhash_v1_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Calculate a 64-bit hash value of the given message.
|
|
37
|
+
*
|
|
38
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
39
|
+
* @param options Options for modifying the hash calculation.
|
|
40
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
41
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
42
|
+
*/
|
|
43
|
+
declare function rapidhash_v2(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate a 64-bit hash value of the given message.
|
|
46
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
47
|
+
*
|
|
48
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
49
|
+
* @param options Options for modifying the hash calculation.
|
|
50
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
51
|
+
*/
|
|
52
|
+
declare function rapidhash_v2_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
53
|
+
/**
|
|
54
|
+
* Calculate a 64-bit hash value of the given message.
|
|
55
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
56
|
+
*
|
|
57
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
58
|
+
* @param options Options for modifying the hash calculation.
|
|
59
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
60
|
+
*/
|
|
61
|
+
declare function rapidhash_v2_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
62
|
+
|
|
63
|
+
export { rapidhash_v2 as rapidhash, rapidhash_v2_fast as rapidhash_fast, rapidhash_v2_protected as rapidhash_protected, rapidhash_v1, rapidhash_v1_fast, rapidhash_v1_protected, rapidhash_v2, rapidhash_v2_fast, rapidhash_v2_protected };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
rapidhash: () => rapidhash_v2,
|
|
24
|
+
rapidhash_fast: () => rapidhash_v2_fast,
|
|
25
|
+
rapidhash_protected: () => rapidhash_v2_protected,
|
|
26
|
+
rapidhash_v1: () => rapidhash_v1,
|
|
27
|
+
rapidhash_v1_fast: () => rapidhash_v1_fast,
|
|
28
|
+
rapidhash_v1_protected: () => rapidhash_v1_protected,
|
|
29
|
+
rapidhash_v2: () => rapidhash_v2,
|
|
30
|
+
rapidhash_v2_fast: () => rapidhash_v2_fast,
|
|
31
|
+
rapidhash_v2_protected: () => rapidhash_v2_protected
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/common.ts
|
|
36
|
+
function rapid_mix_fast(a, b) {
|
|
37
|
+
const m = a * b;
|
|
38
|
+
return BigInt.asUintN(64, m) ^ m >> 64n;
|
|
39
|
+
}
|
|
40
|
+
function rapidhash_epilogue_fast(a, b, secretA, secretB, len) {
|
|
41
|
+
const m0 = a * b;
|
|
42
|
+
const m1 = (BigInt.asUintN(64, m0) ^ secretA ^ len) * (m0 >> 64n ^ secretB);
|
|
43
|
+
return BigInt.asUintN(64, m1) ^ m1 >> 64n;
|
|
44
|
+
}
|
|
45
|
+
function rapid_mix_protected(a, b) {
|
|
46
|
+
const m = a * b;
|
|
47
|
+
return BigInt.asUintN(64, m) ^ m >> 64n ^ a ^ b;
|
|
48
|
+
}
|
|
49
|
+
function rapidhash_epilogue_protected(a0, b0, secretA, secretB, len) {
|
|
50
|
+
const m0 = a0 * b0;
|
|
51
|
+
const a1 = BigInt.asUintN(64, m0) ^ secretA ^ len ^ a0;
|
|
52
|
+
const b1 = m0 >> 64n ^ secretB ^ b0;
|
|
53
|
+
const m1 = a1 * b1;
|
|
54
|
+
return BigInt.asUintN(64, m1) ^ m1 >> 64n ^ a1 ^ b1;
|
|
55
|
+
}
|
|
56
|
+
var read32x2Buffer = new Uint8Array(8);
|
|
57
|
+
var read32x2View = new DataView(read32x2Buffer.buffer);
|
|
58
|
+
function rapid_read32x2(buf, offset1, offset2) {
|
|
59
|
+
read32x2View.setUint32(4, buf.getUint32(offset1, true), true);
|
|
60
|
+
read32x2View.setUint32(0, buf.getUint32(offset2, true), true);
|
|
61
|
+
return read32x2View.getBigUint64(0, true);
|
|
62
|
+
}
|
|
63
|
+
var read32Buffer = new Uint8Array(8);
|
|
64
|
+
var read32View = new DataView(read32Buffer.buffer);
|
|
65
|
+
function rapid_read32(buf, offset) {
|
|
66
|
+
read32View.setUint32(0, buf.getUint32(offset, true), true);
|
|
67
|
+
return read32View.getBigUint64(0, true);
|
|
68
|
+
}
|
|
69
|
+
function rapid_read64(buf, offset) {
|
|
70
|
+
return buf.getBigUint64(offset, true);
|
|
71
|
+
}
|
|
72
|
+
var readSmallBuffer = new Uint8Array(8);
|
|
73
|
+
var readSmallView = new DataView(readSmallBuffer.buffer);
|
|
74
|
+
function rapid_readSmall(buf, offset, k) {
|
|
75
|
+
readSmallBuffer[7] = buf.getUint8(offset);
|
|
76
|
+
readSmallBuffer[4] = buf.getUint8(offset + (k >> 1));
|
|
77
|
+
readSmallBuffer[0] = buf.getUint8(offset + k - 1);
|
|
78
|
+
return readSmallView.getBigUint64(0, true);
|
|
79
|
+
}
|
|
80
|
+
var textEncoder = new TextEncoder();
|
|
81
|
+
var utf8BufferSize = 2048;
|
|
82
|
+
var stringLengthThresholdToUseBuffer = utf8BufferSize / 3;
|
|
83
|
+
var utf8Buffer = new Uint8Array(utf8BufferSize);
|
|
84
|
+
function toDataView(message) {
|
|
85
|
+
if (typeof message === "string") {
|
|
86
|
+
if (message.length <= stringLengthThresholdToUseBuffer) {
|
|
87
|
+
const { written } = textEncoder.encodeInto(message, utf8Buffer);
|
|
88
|
+
return new DataView(utf8Buffer.buffer, 0, written);
|
|
89
|
+
}
|
|
90
|
+
const utf8bytes = textEncoder.encode(message);
|
|
91
|
+
return new DataView(utf8bytes.buffer, utf8bytes.byteOffset, utf8bytes.byteLength);
|
|
92
|
+
}
|
|
93
|
+
if (message instanceof Uint8Array) {
|
|
94
|
+
return new DataView(message.buffer, message.byteOffset, message.byteLength);
|
|
95
|
+
}
|
|
96
|
+
return message;
|
|
97
|
+
}
|
|
98
|
+
var defaultRapidMumBehaviour = "fast";
|
|
99
|
+
function isBigUint64(value) {
|
|
100
|
+
return value >= 0n && value <= 0xffffffffffffffffn;
|
|
101
|
+
}
|
|
102
|
+
function validateOptions(options, defaultSeed) {
|
|
103
|
+
const result = {
|
|
104
|
+
seed: defaultSeed,
|
|
105
|
+
rapidMumBehaviour: defaultRapidMumBehaviour
|
|
106
|
+
};
|
|
107
|
+
if (options === void 0) {
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
if (options.seed !== void 0) {
|
|
111
|
+
if (!isBigUint64(options.seed)) {
|
|
112
|
+
throw new Error(`seed must be a 64-bit unsigned bigint value: ${options.seed}`);
|
|
113
|
+
}
|
|
114
|
+
result.seed = options.seed;
|
|
115
|
+
}
|
|
116
|
+
if (options.rapidMumBehaviour !== void 0) {
|
|
117
|
+
result.rapidMumBehaviour = options.rapidMumBehaviour;
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/rapidhash_v1.ts
|
|
123
|
+
var RAPID_SEED = 0xbdd89aa982704029n;
|
|
124
|
+
var rapid_secret = [0x2d358dccaa6c78a5n, 0x8bb84b93962eacc9n, 0x4b33a62ed433d4a3n];
|
|
125
|
+
function rapidhash_v1_internal(key, seed, secret, rapid_mix, rapidhash_epilogue) {
|
|
126
|
+
const len = key.byteLength;
|
|
127
|
+
const lenBI = BigInt(key.byteLength);
|
|
128
|
+
seed ^= rapid_mix(seed ^ secret[0], secret[1]) ^ lenBI;
|
|
129
|
+
let a;
|
|
130
|
+
let b;
|
|
131
|
+
if (len <= 16) {
|
|
132
|
+
if (len >= 4) {
|
|
133
|
+
const last = len - 4;
|
|
134
|
+
a = rapid_read32x2(key, 0, last);
|
|
135
|
+
const delta = (len & 24) >> (len >> 3);
|
|
136
|
+
b = rapid_read32x2(key, delta, last - delta);
|
|
137
|
+
} else if (len > 0) {
|
|
138
|
+
a = rapid_readSmall(key, 0, len);
|
|
139
|
+
b = 0n;
|
|
140
|
+
} else {
|
|
141
|
+
a = 0n;
|
|
142
|
+
b = 0n;
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
let i = len;
|
|
146
|
+
let p = 0;
|
|
147
|
+
if (i > 48) {
|
|
148
|
+
let see1 = seed;
|
|
149
|
+
let see2 = seed;
|
|
150
|
+
while (i >= 96) {
|
|
151
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
152
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
153
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
154
|
+
seed = rapid_mix(rapid_read64(key, p + 48) ^ secret[0], rapid_read64(key, p + 56) ^ seed);
|
|
155
|
+
see1 = rapid_mix(rapid_read64(key, p + 64) ^ secret[1], rapid_read64(key, p + 72) ^ see1);
|
|
156
|
+
see2 = rapid_mix(rapid_read64(key, p + 80) ^ secret[2], rapid_read64(key, p + 88) ^ see2);
|
|
157
|
+
p += 96;
|
|
158
|
+
i -= 96;
|
|
159
|
+
}
|
|
160
|
+
if (i >= 48) {
|
|
161
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
162
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
163
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
164
|
+
p += 48;
|
|
165
|
+
i -= 48;
|
|
166
|
+
}
|
|
167
|
+
seed ^= see1 ^ see2;
|
|
168
|
+
}
|
|
169
|
+
if (i > 16) {
|
|
170
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed ^ secret[1]);
|
|
171
|
+
if (i > 32) {
|
|
172
|
+
seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
a = rapid_read64(key, p + i - 16);
|
|
176
|
+
b = rapid_read64(key, p + i - 8);
|
|
177
|
+
}
|
|
178
|
+
a ^= secret[1];
|
|
179
|
+
b ^= seed;
|
|
180
|
+
return rapidhash_epilogue(a, b, secret[0], secret[1], lenBI);
|
|
181
|
+
}
|
|
182
|
+
var rapidMumImplementations = {
|
|
183
|
+
fast: {
|
|
184
|
+
rapid_mix: rapid_mix_fast,
|
|
185
|
+
rapidhash_epilogue: rapidhash_epilogue_fast
|
|
186
|
+
},
|
|
187
|
+
protected: {
|
|
188
|
+
rapid_mix: rapid_mix_protected,
|
|
189
|
+
rapidhash_epilogue: rapidhash_epilogue_protected
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
function rapidhash_v1(message, options) {
|
|
193
|
+
const { seed, rapidMumBehaviour } = validateOptions(options, RAPID_SEED);
|
|
194
|
+
const { rapid_mix, rapidhash_epilogue } = rapidMumImplementations[rapidMumBehaviour];
|
|
195
|
+
return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);
|
|
196
|
+
}
|
|
197
|
+
function rapidhash_v1_fast(message, options) {
|
|
198
|
+
const { seed } = validateOptions(options, RAPID_SEED);
|
|
199
|
+
return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);
|
|
200
|
+
}
|
|
201
|
+
function rapidhash_v1_protected(message, options) {
|
|
202
|
+
const { seed } = validateOptions(options, RAPID_SEED);
|
|
203
|
+
return rapidhash_v1_internal(
|
|
204
|
+
toDataView(message),
|
|
205
|
+
seed,
|
|
206
|
+
rapid_secret,
|
|
207
|
+
rapid_mix_protected,
|
|
208
|
+
rapidhash_epilogue_protected
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/rapidhash_v2.ts
|
|
213
|
+
var RAPID_SEED2 = 0n;
|
|
214
|
+
var rapid_secret2 = [
|
|
215
|
+
0x2d358dccaa6c78a5n,
|
|
216
|
+
0x8bb84b93962eacc9n,
|
|
217
|
+
0x4b33a62ed433d4a3n,
|
|
218
|
+
0x4d5a2da51de1aa47n,
|
|
219
|
+
0xa0761d6478bd642fn,
|
|
220
|
+
0xe7037ed1a0b428dbn,
|
|
221
|
+
0x90ed1765281c388cn,
|
|
222
|
+
0xaaaaaaaaaaaaaaaan
|
|
223
|
+
];
|
|
224
|
+
function rapidhash_v2_internal(key, seed, secret, rapid_mix, rapidhash_epilogue) {
|
|
225
|
+
const len = key.byteLength;
|
|
226
|
+
const lenBI = BigInt(key.byteLength);
|
|
227
|
+
seed ^= rapid_mix(seed ^ secret[2], secret[1]) ^ lenBI;
|
|
228
|
+
let a;
|
|
229
|
+
let b;
|
|
230
|
+
if (len <= 16) {
|
|
231
|
+
if (len >= 4) {
|
|
232
|
+
if (len >= 8) {
|
|
233
|
+
const last = len - 8;
|
|
234
|
+
a = rapid_read64(key, 0);
|
|
235
|
+
b = rapid_read64(key, last);
|
|
236
|
+
} else {
|
|
237
|
+
const last = len - 4;
|
|
238
|
+
a = rapid_read32(key, 0);
|
|
239
|
+
b = rapid_read32(key, last);
|
|
240
|
+
}
|
|
241
|
+
} else if (len > 0) {
|
|
242
|
+
a = rapid_readSmall(key, 0, len);
|
|
243
|
+
b = 0n;
|
|
244
|
+
} else {
|
|
245
|
+
a = 0n;
|
|
246
|
+
b = 0n;
|
|
247
|
+
}
|
|
248
|
+
} else if (len > 56) {
|
|
249
|
+
let i = len;
|
|
250
|
+
let p = 0;
|
|
251
|
+
let see1 = seed;
|
|
252
|
+
let see2 = seed;
|
|
253
|
+
let see3 = seed;
|
|
254
|
+
let see4 = seed;
|
|
255
|
+
let see5 = seed;
|
|
256
|
+
let see6 = seed;
|
|
257
|
+
while (i >= 224) {
|
|
258
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
259
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
260
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
261
|
+
see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);
|
|
262
|
+
see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);
|
|
263
|
+
see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);
|
|
264
|
+
see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);
|
|
265
|
+
seed = rapid_mix(rapid_read64(key, p + 112) ^ secret[0], rapid_read64(key, p + 120) ^ seed);
|
|
266
|
+
see1 = rapid_mix(rapid_read64(key, p + 128) ^ secret[1], rapid_read64(key, p + 136) ^ see1);
|
|
267
|
+
see2 = rapid_mix(rapid_read64(key, p + 144) ^ secret[2], rapid_read64(key, p + 152) ^ see2);
|
|
268
|
+
see3 = rapid_mix(rapid_read64(key, p + 160) ^ secret[3], rapid_read64(key, p + 168) ^ see3);
|
|
269
|
+
see4 = rapid_mix(rapid_read64(key, p + 176) ^ secret[4], rapid_read64(key, p + 184) ^ see4);
|
|
270
|
+
see5 = rapid_mix(rapid_read64(key, p + 192) ^ secret[5], rapid_read64(key, p + 200) ^ see5);
|
|
271
|
+
see6 = rapid_mix(rapid_read64(key, p + 208) ^ secret[6], rapid_read64(key, p + 216) ^ see6);
|
|
272
|
+
p += 224;
|
|
273
|
+
i -= 224;
|
|
274
|
+
}
|
|
275
|
+
if (i >= 112) {
|
|
276
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
277
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
278
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
279
|
+
see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);
|
|
280
|
+
see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);
|
|
281
|
+
see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);
|
|
282
|
+
see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);
|
|
283
|
+
p += 112;
|
|
284
|
+
i -= 112;
|
|
285
|
+
}
|
|
286
|
+
if (i >= 48) {
|
|
287
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
288
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
289
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
290
|
+
p += 48;
|
|
291
|
+
i -= 48;
|
|
292
|
+
if (i >= 48) {
|
|
293
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
294
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
295
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
296
|
+
p += 48;
|
|
297
|
+
i -= 48;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
see3 ^= see4;
|
|
301
|
+
see5 ^= see6;
|
|
302
|
+
seed ^= see1;
|
|
303
|
+
see3 ^= see2;
|
|
304
|
+
seed ^= see5;
|
|
305
|
+
seed ^= see3;
|
|
306
|
+
if (i > 16) {
|
|
307
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed);
|
|
308
|
+
if (i > 32) {
|
|
309
|
+
seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
a = rapid_read64(key, p + i - 16);
|
|
313
|
+
b = rapid_read64(key, p + i - 8);
|
|
314
|
+
} else {
|
|
315
|
+
seed = rapid_mix(rapid_read64(key, 0) ^ secret[0], rapid_read64(key, 8) ^ seed);
|
|
316
|
+
if (len > 32) {
|
|
317
|
+
seed = rapid_mix(rapid_read64(key, 16) ^ secret[1], rapid_read64(key, 24) ^ seed);
|
|
318
|
+
if (len > 48) {
|
|
319
|
+
seed = rapid_mix(rapid_read64(key, 32) ^ secret[0], rapid_read64(key, 40) ^ seed);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
a = rapid_read64(key, len - 16);
|
|
323
|
+
b = rapid_read64(key, len - 8);
|
|
324
|
+
}
|
|
325
|
+
a ^= secret[1];
|
|
326
|
+
b ^= seed;
|
|
327
|
+
return rapidhash_epilogue(a, b, secret[7], secret[1], lenBI);
|
|
328
|
+
}
|
|
329
|
+
var rapidMumImplementations2 = {
|
|
330
|
+
fast: {
|
|
331
|
+
rapid_mix: rapid_mix_fast,
|
|
332
|
+
rapidhash_epilogue: rapidhash_epilogue_fast
|
|
333
|
+
},
|
|
334
|
+
protected: {
|
|
335
|
+
rapid_mix: rapid_mix_protected,
|
|
336
|
+
rapidhash_epilogue: rapidhash_epilogue_protected
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
function rapidhash_v2(message, options) {
|
|
340
|
+
const { seed, rapidMumBehaviour } = validateOptions(options, RAPID_SEED2);
|
|
341
|
+
const { rapid_mix, rapidhash_epilogue } = rapidMumImplementations2[rapidMumBehaviour];
|
|
342
|
+
return rapidhash_v2_internal(toDataView(message), seed, rapid_secret2, rapid_mix, rapidhash_epilogue);
|
|
343
|
+
}
|
|
344
|
+
function rapidhash_v2_fast(message, options) {
|
|
345
|
+
const { seed } = validateOptions(options, RAPID_SEED2);
|
|
346
|
+
return rapidhash_v2_internal(toDataView(message), seed, rapid_secret2, rapid_mix_fast, rapidhash_epilogue_fast);
|
|
347
|
+
}
|
|
348
|
+
function rapidhash_v2_protected(message, options) {
|
|
349
|
+
const { seed } = validateOptions(options, RAPID_SEED2);
|
|
350
|
+
return rapidhash_v2_internal(
|
|
351
|
+
toDataView(message),
|
|
352
|
+
seed,
|
|
353
|
+
rapid_secret2,
|
|
354
|
+
rapid_mix_protected,
|
|
355
|
+
rapidhash_epilogue_protected
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
359
|
+
0 && (module.exports = {
|
|
360
|
+
rapidhash,
|
|
361
|
+
rapidhash_fast,
|
|
362
|
+
rapidhash_protected,
|
|
363
|
+
rapidhash_v1,
|
|
364
|
+
rapidhash_v1_fast,
|
|
365
|
+
rapidhash_v1_protected,
|
|
366
|
+
rapidhash_v2,
|
|
367
|
+
rapidhash_v2_fast,
|
|
368
|
+
rapidhash_v2_protected
|
|
369
|
+
});
|
|
370
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/common.ts","../src/rapidhash_v1.ts","../src/rapidhash_v2.ts"],"sourcesContent":["import {rapidhash_v1, rapidhash_v1_fast, rapidhash_v1_protected} from './rapidhash_v1';\nimport {rapidhash_v2, rapidhash_v2_fast, rapidhash_v2_protected} from './rapidhash_v2';\n\nexport {\n rapidhash_v1,\n rapidhash_v1_fast,\n rapidhash_v1_protected,\n rapidhash_v2,\n rapidhash_v2_fast,\n rapidhash_v2_protected,\n // Default version is v2\n rapidhash_v2 as rapidhash,\n rapidhash_v2_fast as rapidhash_fast,\n rapidhash_v2_protected as rapidhash_protected,\n};\n","export type RapidMix = (a: bigint, b: bigint) => bigint;\nexport type RapidhashEpilogue = (a: bigint, b: bigint, secretA: bigint, secretB: bigint, len: bigint) => bigint;\n\nexport function rapid_mix_fast(a: bigint, b: bigint): bigint {\n const m = a * b;\n return BigInt.asUintN(64, m) ^ (m >> 64n);\n}\n\nexport function rapidhash_epilogue_fast(a: bigint, b: bigint, secretA: bigint, secretB: bigint, len: bigint): bigint {\n const m0 = a * b;\n const m1 = (BigInt.asUintN(64, m0) ^ secretA ^ len) * ((m0 >> 64n) ^ secretB);\n return BigInt.asUintN(64, m1) ^ (m1 >> 64n);\n}\n\nexport function rapid_mix_protected(a: bigint, b: bigint): bigint {\n const m = a * b;\n return BigInt.asUintN(64, m) ^ (m >> 64n) ^ a ^ b;\n}\n\nexport function rapidhash_epilogue_protected(\n a0: bigint,\n b0: bigint,\n secretA: bigint,\n secretB: bigint,\n len: bigint,\n): bigint {\n const m0 = a0 * b0;\n const a1 = BigInt.asUintN(64, m0) ^ secretA ^ len ^ a0;\n const b1 = (m0 >> 64n) ^ secretB ^ b0;\n const m1 = a1 * b1;\n return BigInt.asUintN(64, m1) ^ (m1 >> 64n) ^ a1 ^ b1;\n}\n\n// ---\n\nconst read32x2Buffer = new Uint8Array(8);\nconst read32x2View = new DataView(read32x2Buffer.buffer);\n\nexport function rapid_read32x2(buf: DataView, offset1: number, offset2: number): bigint {\n read32x2View.setUint32(4, buf.getUint32(offset1, true), true);\n read32x2View.setUint32(0, buf.getUint32(offset2, true), true);\n return read32x2View.getBigUint64(0, true);\n}\n\nconst read32Buffer = new Uint8Array(8);\nconst read32View = new DataView(read32Buffer.buffer);\n\nexport function rapid_read32(buf: DataView, offset: number): bigint {\n read32View.setUint32(0, buf.getUint32(offset, true), true);\n return read32View.getBigUint64(0, true);\n}\n\nexport function rapid_read64(buf: DataView, offset: number): bigint {\n return buf.getBigUint64(offset, true);\n}\n\nconst readSmallBuffer = new Uint8Array(8);\nconst readSmallView = new DataView(readSmallBuffer.buffer);\n\nexport function rapid_readSmall(buf: DataView, offset: number, k: number): bigint {\n readSmallBuffer[7] = buf.getUint8(offset);\n readSmallBuffer[4] = buf.getUint8(offset + (k >> 1));\n readSmallBuffer[0] = buf.getUint8(offset + k - 1);\n return readSmallView.getBigUint64(0, true);\n}\n\n// ---\n\nconst textEncoder = new TextEncoder();\nconst utf8BufferSize = 2048;\nconst stringLengthThresholdToUseBuffer = utf8BufferSize / 3;\nconst utf8Buffer = new Uint8Array(utf8BufferSize);\n\nexport function toDataView(message: string | Uint8Array | DataView): DataView {\n if (typeof message === 'string') {\n if (message.length <= stringLengthThresholdToUseBuffer) {\n const {written} = textEncoder.encodeInto(message, utf8Buffer);\n return new DataView(utf8Buffer.buffer, 0, written);\n }\n\n const utf8bytes = textEncoder.encode(message);\n return new DataView(utf8bytes.buffer, utf8bytes.byteOffset, utf8bytes.byteLength);\n }\n\n if (message instanceof Uint8Array) {\n return new DataView(message.buffer, message.byteOffset, message.byteLength);\n }\n\n return message;\n}\n\n// ---\n\nexport type RapidMumBehaviour = 'fast' | 'protected';\nconst defaultRapidMumBehaviour: RapidMumBehaviour = 'fast';\n\nexport interface RapidhashOptions {\n seed: bigint;\n rapidMumBehaviour: RapidMumBehaviour;\n}\n\nfunction isBigUint64(value: bigint): boolean {\n return value >= 0n && value <= 0xffff_ffff_ffff_ffffn;\n}\n\nexport function validateOptions(options: Partial<RapidhashOptions> | undefined, defaultSeed: bigint): RapidhashOptions {\n const result: RapidhashOptions = {\n seed: defaultSeed,\n rapidMumBehaviour: defaultRapidMumBehaviour,\n };\n\n if (options === undefined) {\n return result;\n }\n\n if (options.seed !== undefined) {\n if (!isBigUint64(options.seed)) {\n throw new Error(`seed must be a 64-bit unsigned bigint value: ${options.seed}`);\n }\n result.seed = options.seed;\n }\n\n if (options.rapidMumBehaviour !== undefined) {\n result.rapidMumBehaviour = options.rapidMumBehaviour;\n }\n\n return result;\n}\n","import {\n type RapidMix,\n type RapidMumBehaviour,\n type RapidhashEpilogue,\n type RapidhashOptions,\n rapid_mix_fast,\n rapid_mix_protected,\n rapid_read32x2,\n rapid_read64,\n rapid_readSmall,\n rapidhash_epilogue_fast,\n rapidhash_epilogue_protected,\n toDataView,\n validateOptions,\n} from './common';\n\ntype RapidSecret = [bigint, bigint, bigint];\n\nconst RAPID_SEED = 0xbdd89aa982704029n;\nconst rapid_secret: RapidSecret = [0x2d358dccaa6c78a5n, 0x8bb84b93962eacc9n, 0x4b33a62ed433d4a3n];\n\n// ---\n\nfunction rapidhash_v1_internal(\n key: DataView,\n seed: bigint,\n secret: RapidSecret,\n rapid_mix: RapidMix,\n rapidhash_epilogue: RapidhashEpilogue,\n): bigint {\n const len = key.byteLength;\n const lenBI = BigInt(key.byteLength);\n\n seed ^= rapid_mix(seed ^ secret[0], secret[1]) ^ lenBI;\n\n let a: bigint;\n let b: bigint;\n\n if (len <= 16) {\n if (len >= 4) {\n const last = len - 4;\n a = rapid_read32x2(key, 0, last);\n const delta = (len & 24) >> (len >> 3);\n b = rapid_read32x2(key, delta, last - delta);\n } else if (len > 0) {\n a = rapid_readSmall(key, 0, len);\n b = 0n;\n } else {\n a = 0n;\n b = 0n;\n }\n } else {\n let i = len;\n let p = 0;\n\n if (i > 48) {\n let see1 = seed;\n let see2 = seed;\n\n while (i >= 96) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n seed = rapid_mix(rapid_read64(key, p + 48) ^ secret[0], rapid_read64(key, p + 56) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 64) ^ secret[1], rapid_read64(key, p + 72) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 80) ^ secret[2], rapid_read64(key, p + 88) ^ see2);\n p += 96;\n i -= 96;\n }\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n }\n\n seed ^= see1 ^ see2;\n }\n\n if (i > 16) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed ^ secret[1]);\n if (i > 32) {\n seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);\n }\n }\n a = rapid_read64(key, p + i - 16);\n b = rapid_read64(key, p + i - 8);\n }\n a ^= secret[1];\n b ^= seed;\n\n return rapidhash_epilogue(a, b, secret[0], secret[1], lenBI);\n}\n\n// ---\n\nconst rapidMumImplementations: {\n [behaviour in RapidMumBehaviour]: {\n rapid_mix: RapidMix;\n rapidhash_epilogue: RapidhashEpilogue;\n };\n} = {\n fast: {\n rapid_mix: rapid_mix_fast,\n rapidhash_epilogue: rapidhash_epilogue_fast,\n },\n protected: {\n rapid_mix: rapid_mix_protected,\n rapidhash_epilogue: rapidhash_epilogue_protected,\n },\n};\n\n/**\n * Calculate a 64-bit hash value of the given message.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n * @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.\n */\nexport function rapidhash_v1(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint {\n const {seed, rapidMumBehaviour} = validateOptions(options, RAPID_SEED);\n const {rapid_mix, rapidhash_epilogue} = rapidMumImplementations[rapidMumBehaviour];\n\n return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v1_fast(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v1_protected(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v1_internal(\n toDataView(message),\n seed,\n rapid_secret,\n rapid_mix_protected,\n rapidhash_epilogue_protected,\n );\n}\n","import {\n type RapidMix,\n type RapidMumBehaviour,\n type RapidhashEpilogue,\n type RapidhashOptions,\n rapid_mix_fast,\n rapid_mix_protected,\n rapid_read32,\n rapid_read64,\n rapid_readSmall,\n rapidhash_epilogue_fast,\n rapidhash_epilogue_protected,\n toDataView,\n validateOptions,\n} from './common';\n\ntype RapidSecret = [bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint];\n\nconst RAPID_SEED = 0n;\nconst rapid_secret: RapidSecret = [\n 0x2d358dccaa6c78a5n,\n 0x8bb84b93962eacc9n,\n 0x4b33a62ed433d4a3n,\n 0x4d5a2da51de1aa47n,\n 0xa0761d6478bd642fn,\n 0xe7037ed1a0b428dbn,\n 0x90ed1765281c388cn,\n 0xaaaaaaaaaaaaaaaan,\n];\n\n// ---\n\nfunction rapidhash_v2_internal(\n key: DataView,\n seed: bigint,\n secret: RapidSecret,\n rapid_mix: RapidMix,\n rapidhash_epilogue: RapidhashEpilogue,\n): bigint {\n const len = key.byteLength;\n const lenBI = BigInt(key.byteLength);\n\n seed ^= rapid_mix(seed ^ secret[2], secret[1]) ^ lenBI;\n\n let a: bigint;\n let b: bigint;\n\n if (len <= 16) {\n if (len >= 4) {\n if (len >= 8) {\n const last = len - 8;\n a = rapid_read64(key, 0);\n b = rapid_read64(key, last);\n } else {\n const last = len - 4;\n a = rapid_read32(key, 0);\n b = rapid_read32(key, last);\n }\n } else if (len > 0) {\n a = rapid_readSmall(key, 0, len);\n b = 0n;\n } else {\n a = 0n;\n b = 0n;\n }\n } else if (len > 56) {\n let i = len;\n let p = 0;\n let see1 = seed;\n let see2 = seed;\n let see3 = seed;\n let see4 = seed;\n let see5 = seed;\n let see6 = seed;\n\n while (i >= 224) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);\n see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);\n see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);\n see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);\n seed = rapid_mix(rapid_read64(key, p + 112) ^ secret[0], rapid_read64(key, p + 120) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 128) ^ secret[1], rapid_read64(key, p + 136) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 144) ^ secret[2], rapid_read64(key, p + 152) ^ see2);\n see3 = rapid_mix(rapid_read64(key, p + 160) ^ secret[3], rapid_read64(key, p + 168) ^ see3);\n see4 = rapid_mix(rapid_read64(key, p + 176) ^ secret[4], rapid_read64(key, p + 184) ^ see4);\n see5 = rapid_mix(rapid_read64(key, p + 192) ^ secret[5], rapid_read64(key, p + 200) ^ see5);\n see6 = rapid_mix(rapid_read64(key, p + 208) ^ secret[6], rapid_read64(key, p + 216) ^ see6);\n p += 224;\n i -= 224;\n }\n\n if (i >= 112) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);\n see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);\n see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);\n see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);\n p += 112;\n i -= 112;\n }\n\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n }\n }\n\n see3 ^= see4;\n see5 ^= see6;\n seed ^= see1;\n see3 ^= see2;\n seed ^= see5;\n seed ^= see3;\n\n if (i > 16) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed);\n if (i > 32) {\n seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);\n }\n }\n\n a = rapid_read64(key, p + i - 16);\n b = rapid_read64(key, p + i - 8);\n } else {\n seed = rapid_mix(rapid_read64(key, 0) ^ secret[0], rapid_read64(key, 8) ^ seed);\n if (len > 32) {\n seed = rapid_mix(rapid_read64(key, 16) ^ secret[1], rapid_read64(key, 24) ^ seed);\n if (len > 48) {\n seed = rapid_mix(rapid_read64(key, 32) ^ secret[0], rapid_read64(key, 40) ^ seed);\n }\n }\n\n a = rapid_read64(key, len - 16);\n b = rapid_read64(key, len - 8);\n }\n a ^= secret[1];\n b ^= seed;\n\n return rapidhash_epilogue(a, b, secret[7], secret[1], lenBI);\n}\n\n// ---\n\nconst rapidMumImplementations: {\n [behaviour in RapidMumBehaviour]: {\n rapid_mix: RapidMix;\n rapidhash_epilogue: RapidhashEpilogue;\n };\n} = {\n fast: {\n rapid_mix: rapid_mix_fast,\n rapidhash_epilogue: rapidhash_epilogue_fast,\n },\n protected: {\n rapid_mix: rapid_mix_protected,\n rapidhash_epilogue: rapidhash_epilogue_protected,\n },\n};\n\n/**\n * Calculate a 64-bit hash value of the given message.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n * @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.\n */\nexport function rapidhash_v2(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint {\n const {seed, rapidMumBehaviour} = validateOptions(options, RAPID_SEED);\n const {rapid_mix, rapidhash_epilogue} = rapidMumImplementations[rapidMumBehaviour];\n\n return rapidhash_v2_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v2_fast(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v2_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v2_protected(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v2_internal(\n toDataView(message),\n seed,\n rapid_secret,\n rapid_mix_protected,\n rapidhash_epilogue_protected,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,SAAS,eAAe,GAAW,GAAmB;AAC3D,QAAM,IAAI,IAAI;AACd,SAAO,OAAO,QAAQ,IAAI,CAAC,IAAK,KAAK;AACvC;AAEO,SAAS,wBAAwB,GAAW,GAAW,SAAiB,SAAiB,KAAqB;AACnH,QAAM,KAAK,IAAI;AACf,QAAM,MAAM,OAAO,QAAQ,IAAI,EAAE,IAAI,UAAU,QAAS,MAAM,MAAO;AACrE,SAAO,OAAO,QAAQ,IAAI,EA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