rapidhash-wasm-vn 1.0.0 → 1.1.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.
@@ -9,6 +9,10 @@
9
9
  * * `seed` - Seed value for hash (default: 0)
10
10
  */
11
11
  export function hash_v1(input: Uint8Array, seed?: bigint | null): bigint;
12
+ /**
13
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
14
+ */
15
+ export function hash_v1_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
12
16
  /**
13
17
  * Computes RapidHash V2 (64-bit) hash
14
18
  *
@@ -18,6 +22,10 @@ export function hash_v1(input: Uint8Array, seed?: bigint | null): bigint;
18
22
  * * `seed` - Seed value for hash (default: 0)
19
23
  */
20
24
  export function hash_v2(input: Uint8Array, seed?: bigint | null): bigint;
25
+ /**
26
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
27
+ */
28
+ export function hash_v2_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
21
29
  /**
22
30
  * Computes RapidHash V3 (64-bit) hash
23
31
  *
@@ -45,6 +53,10 @@ export function hash_v3_micro(input: Uint8Array, seed?: bigint | null): bigint;
45
53
  * * `seed` - Seed value for hash (default: 0)
46
54
  */
47
55
  export function hash_v3_nano(input: Uint8Array, seed?: bigint | null): bigint;
56
+ /**
57
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
58
+ */
59
+ export function hash_v3_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
48
60
  export class FastHasher {
49
61
  free(): void;
50
62
  [Symbol.dispose](): void;
@@ -13,6 +13,11 @@ function getUint8ArrayMemory0() {
13
13
  return cachedUint8ArrayMemory0;
14
14
  }
15
15
 
16
+ function getArrayU8FromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
19
+ }
20
+
16
21
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
22
 
18
23
  cachedTextDecoder.decode();
@@ -64,6 +69,68 @@ export function hash_v1(input, seed) {
64
69
  return BigInt.asUintN(64, ret);
65
70
  }
66
71
 
72
+ let cachedDataViewMemory0 = null;
73
+
74
+ function getDataViewMemory0() {
75
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
76
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
77
+ }
78
+ return cachedDataViewMemory0;
79
+ }
80
+
81
+ function addToExternrefTable0(obj) {
82
+ const idx = wasm.__externref_table_alloc();
83
+ wasm.__wbindgen_export_0.set(idx, obj);
84
+ return idx;
85
+ }
86
+
87
+ function passArrayJsValueToWasm0(array, malloc) {
88
+ const ptr = malloc(array.length * 4, 4) >>> 0;
89
+ for (let i = 0; i < array.length; i++) {
90
+ const add = addToExternrefTable0(array[i]);
91
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
92
+ }
93
+ WASM_VECTOR_LEN = array.length;
94
+ return ptr;
95
+ }
96
+
97
+ function takeFromExternrefTable0(idx) {
98
+ const value = wasm.__wbindgen_export_0.get(idx);
99
+ wasm.__externref_table_dealloc(idx);
100
+ return value;
101
+ }
102
+
103
+ let cachedBigUint64ArrayMemory0 = null;
104
+
105
+ function getBigUint64ArrayMemory0() {
106
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
107
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
108
+ }
109
+ return cachedBigUint64ArrayMemory0;
110
+ }
111
+
112
+ function getArrayU64FromWasm0(ptr, len) {
113
+ ptr = ptr >>> 0;
114
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
115
+ }
116
+ /**
117
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
118
+ * @param {Uint8Array[]} chunks
119
+ * @param {bigint | null} [seed]
120
+ * @returns {BigUint64Array}
121
+ */
122
+ export function hash_v1_batch(chunks, seed) {
123
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
124
+ const len0 = WASM_VECTOR_LEN;
125
+ const ret = wasm.hash_v1_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
126
+ if (ret[3]) {
127
+ throw takeFromExternrefTable0(ret[2]);
128
+ }
129
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
130
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
131
+ return v2;
132
+ }
133
+
67
134
  /**
68
135
  * Computes RapidHash V2 (64-bit) hash
69
136
  *
@@ -82,6 +149,24 @@ export function hash_v2(input, seed) {
82
149
  return BigInt.asUintN(64, ret);
83
150
  }
84
151
 
152
+ /**
153
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
154
+ * @param {Uint8Array[]} chunks
155
+ * @param {bigint | null} [seed]
156
+ * @returns {BigUint64Array}
157
+ */
158
+ export function hash_v2_batch(chunks, seed) {
159
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
160
+ const len0 = WASM_VECTOR_LEN;
161
+ const ret = wasm.hash_v2_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
162
+ if (ret[3]) {
163
+ throw takeFromExternrefTable0(ret[2]);
164
+ }
165
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
166
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
167
+ return v2;
168
+ }
169
+
85
170
  /**
86
171
  * Computes RapidHash V3 (64-bit) hash
87
172
  *
@@ -136,6 +221,24 @@ export function hash_v3_nano(input, seed) {
136
221
  return BigInt.asUintN(64, ret);
137
222
  }
138
223
 
224
+ /**
225
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
226
+ * @param {Uint8Array[]} chunks
227
+ * @param {bigint | null} [seed]
228
+ * @returns {BigUint64Array}
229
+ */
230
+ export function hash_v3_batch(chunks, seed) {
231
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
232
+ const len0 = WASM_VECTOR_LEN;
233
+ const ret = wasm.hash_v3_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
234
+ if (ret[3]) {
235
+ throw takeFromExternrefTable0(ret[2]);
236
+ }
237
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
238
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
239
+ return v2;
240
+ }
241
+
139
242
  const FastHasherFinalization = (typeof FinalizationRegistry === 'undefined')
140
243
  ? { register: () => {}, unregister: () => {} }
141
244
  : new FinalizationRegistry(ptr => wasm.__wbg_fasthasher_free(ptr >>> 0, 1));
@@ -522,6 +625,15 @@ export class QualityHasher {
522
625
  }
523
626
  if (Symbol.dispose) QualityHasher.prototype[Symbol.dispose] = QualityHasher.prototype.free;
524
627
 
628
+ export function __wbg_length_6bb7e81f9d7713e4(arg0) {
629
+ const ret = arg0.length;
630
+ return ret;
631
+ };
632
+
633
+ export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
634
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
635
+ };
636
+
525
637
  export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
526
638
  throw new Error(getStringFromWasm0(arg0, arg1));
527
639
  };
Binary file
@@ -7,16 +7,19 @@ export const portablehashv1_new: (a: number, b: bigint) => number;
7
7
  export const portablehashv1_update: (a: number, b: number, c: number) => void;
8
8
  export const portablehashv1_digest: (a: number) => bigint;
9
9
  export const portablehashv1_reset: (a: number) => void;
10
+ export const hash_v1_batch: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
10
11
  export const hash_v2: (a: number, b: number, c: number, d: bigint) => bigint;
11
12
  export const __wbg_portablehashv2_free: (a: number, b: number) => void;
12
13
  export const portablehashv2_new: (a: number, b: bigint) => number;
13
14
  export const portablehashv2_update: (a: number, b: number, c: number) => void;
14
15
  export const portablehashv2_digest: (a: number) => bigint;
15
16
  export const portablehashv2_reset: (a: number) => void;
17
+ export const hash_v2_batch: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
16
18
  export const hash_v3: (a: number, b: number, c: number, d: bigint) => bigint;
17
19
  export const hash_v3_micro: (a: number, b: number, c: number, d: bigint) => bigint;
18
20
  export const hash_v3_nano: (a: number, b: number, c: number, d: bigint) => bigint;
19
21
  export const portablehashv3_digest: (a: number) => bigint;
22
+ export const hash_v3_batch: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
20
23
  export const __wbg_fasthasher_free: (a: number, b: number) => void;
21
24
  export const fasthasher_new: (a: number, b: bigint) => number;
22
25
  export const fasthasher_update: (a: number, b: number, c: number) => void;
@@ -29,21 +32,21 @@ export const fasthasher_digest: (a: number) => bigint;
29
32
  export const fasthasher_reset: (a: number) => void;
30
33
  export const qualityhasher_update: (a: number, b: number, c: number) => void;
31
34
  export const qualityhasher_digest: (a: number) => bigint;
35
+ export const fasthasher_update_u128: (a: number, b: bigint, c: bigint) => void;
36
+ export const qualityhasher_update_u128: (a: number, b: bigint, c: bigint) => void;
32
37
  export const fasthasher_update_u8: (a: number, b: number) => void;
33
38
  export const fasthasher_update_u16: (a: number, b: number) => void;
34
39
  export const qualityhasher_update_u8: (a: number, b: number) => void;
35
40
  export const qualityhasher_update_u16: (a: number, b: number) => void;
36
- export const fasthasher_update_u128: (a: number, b: bigint, c: bigint) => void;
37
- export const qualityhasher_update_u128: (a: number, b: bigint, c: bigint) => void;
41
+ export const qualityhasher_new: (a: number, b: bigint) => number;
38
42
  export const fasthasher_update_u32: (a: number, b: number) => void;
39
43
  export const fasthasher_update_u64: (a: number, b: bigint) => void;
40
44
  export const qualityhasher_update_u32: (a: number, b: number) => void;
41
45
  export const qualityhasher_update_u64: (a: number, b: bigint) => void;
42
- export const qualityhasher_new: (a: number, b: bigint) => number;
46
+ export const qualityhasher_reset: (a: number) => void;
43
47
  export const __wbg_qualityhasher_free: (a: number, b: number) => void;
44
48
  export const __wbg_portablehashv3_free: (a: number, b: number) => void;
45
49
  export const portablehashv3_reset: (a: number) => void;
46
- export const qualityhasher_reset: (a: number) => void;
47
50
  export const qualityhasher_update_i128: (a: number, b: bigint, c: bigint) => void;
48
51
  export const qualityhasher_update_i64: (a: number, b: bigint) => void;
49
52
  export const qualityhasher_update_i32: (a: number, b: number) => void;
@@ -53,4 +56,7 @@ export const portablehashv3_update: (a: number, b: number, c: number) => void;
53
56
  export const portablehashv3_new: (a: number, b: bigint) => number;
54
57
  export const __wbindgen_export_0: WebAssembly.Table;
55
58
  export const __wbindgen_malloc: (a: number, b: number) => number;
59
+ export const __externref_table_alloc: () => number;
60
+ export const __externref_table_dealloc: (a: number) => void;
61
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
56
62
  export const __wbindgen_start: () => void;
@@ -9,6 +9,10 @@
9
9
  * * `seed` - Seed value for hash (default: 0)
10
10
  */
11
11
  export function hash_v1(input: Uint8Array, seed?: bigint | null): bigint;
12
+ /**
13
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
14
+ */
15
+ export function hash_v1_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
12
16
  /**
13
17
  * Computes RapidHash V2 (64-bit) hash
14
18
  *
@@ -18,6 +22,10 @@ export function hash_v1(input: Uint8Array, seed?: bigint | null): bigint;
18
22
  * * `seed` - Seed value for hash (default: 0)
19
23
  */
20
24
  export function hash_v2(input: Uint8Array, seed?: bigint | null): bigint;
25
+ /**
26
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
27
+ */
28
+ export function hash_v2_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
21
29
  /**
22
30
  * Computes RapidHash V3 (64-bit) hash
23
31
  *
@@ -45,6 +53,10 @@ export function hash_v3_micro(input: Uint8Array, seed?: bigint | null): bigint;
45
53
  * * `seed` - Seed value for hash (default: 0)
46
54
  */
47
55
  export function hash_v3_nano(input: Uint8Array, seed?: bigint | null): bigint;
56
+ /**
57
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
58
+ */
59
+ export function hash_v3_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
48
60
  export class FastHasher {
49
61
  free(): void;
50
62
  [Symbol.dispose](): void;
@@ -9,6 +9,11 @@ function getUint8ArrayMemory0() {
9
9
  return cachedUint8ArrayMemory0;
10
10
  }
11
11
 
12
+ function getArrayU8FromWasm0(ptr, len) {
13
+ ptr = ptr >>> 0;
14
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
15
+ }
16
+
12
17
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
18
 
14
19
  cachedTextDecoder.decode();
@@ -52,6 +57,68 @@ export function hash_v1(input, seed) {
52
57
  return BigInt.asUintN(64, ret);
53
58
  }
54
59
 
60
+ let cachedDataViewMemory0 = null;
61
+
62
+ function getDataViewMemory0() {
63
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
64
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
65
+ }
66
+ return cachedDataViewMemory0;
67
+ }
68
+
69
+ function addToExternrefTable0(obj) {
70
+ const idx = wasm.__externref_table_alloc();
71
+ wasm.__wbindgen_export_0.set(idx, obj);
72
+ return idx;
73
+ }
74
+
75
+ function passArrayJsValueToWasm0(array, malloc) {
76
+ const ptr = malloc(array.length * 4, 4) >>> 0;
77
+ for (let i = 0; i < array.length; i++) {
78
+ const add = addToExternrefTable0(array[i]);
79
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
80
+ }
81
+ WASM_VECTOR_LEN = array.length;
82
+ return ptr;
83
+ }
84
+
85
+ function takeFromExternrefTable0(idx) {
86
+ const value = wasm.__wbindgen_export_0.get(idx);
87
+ wasm.__externref_table_dealloc(idx);
88
+ return value;
89
+ }
90
+
91
+ let cachedBigUint64ArrayMemory0 = null;
92
+
93
+ function getBigUint64ArrayMemory0() {
94
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
95
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
96
+ }
97
+ return cachedBigUint64ArrayMemory0;
98
+ }
99
+
100
+ function getArrayU64FromWasm0(ptr, len) {
101
+ ptr = ptr >>> 0;
102
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
103
+ }
104
+ /**
105
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
106
+ * @param {Uint8Array[]} chunks
107
+ * @param {bigint | null} [seed]
108
+ * @returns {BigUint64Array}
109
+ */
110
+ export function hash_v1_batch(chunks, seed) {
111
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.hash_v1_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
114
+ if (ret[3]) {
115
+ throw takeFromExternrefTable0(ret[2]);
116
+ }
117
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
118
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
119
+ return v2;
120
+ }
121
+
55
122
  /**
56
123
  * Computes RapidHash V2 (64-bit) hash
57
124
  *
@@ -70,6 +137,24 @@ export function hash_v2(input, seed) {
70
137
  return BigInt.asUintN(64, ret);
71
138
  }
72
139
 
140
+ /**
141
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
142
+ * @param {Uint8Array[]} chunks
143
+ * @param {bigint | null} [seed]
144
+ * @returns {BigUint64Array}
145
+ */
146
+ export function hash_v2_batch(chunks, seed) {
147
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
148
+ const len0 = WASM_VECTOR_LEN;
149
+ const ret = wasm.hash_v2_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
150
+ if (ret[3]) {
151
+ throw takeFromExternrefTable0(ret[2]);
152
+ }
153
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
154
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
155
+ return v2;
156
+ }
157
+
73
158
  /**
74
159
  * Computes RapidHash V3 (64-bit) hash
75
160
  *
@@ -124,6 +209,24 @@ export function hash_v3_nano(input, seed) {
124
209
  return BigInt.asUintN(64, ret);
125
210
  }
126
211
 
212
+ /**
213
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
214
+ * @param {Uint8Array[]} chunks
215
+ * @param {bigint | null} [seed]
216
+ * @returns {BigUint64Array}
217
+ */
218
+ export function hash_v3_batch(chunks, seed) {
219
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ const ret = wasm.hash_v3_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
222
+ if (ret[3]) {
223
+ throw takeFromExternrefTable0(ret[2]);
224
+ }
225
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
226
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
227
+ return v2;
228
+ }
229
+
127
230
  const FastHasherFinalization = (typeof FinalizationRegistry === 'undefined')
128
231
  ? { register: () => {}, unregister: () => {} }
129
232
  : new FinalizationRegistry(ptr => wasm.__wbg_fasthasher_free(ptr >>> 0, 1));
@@ -512,6 +615,13 @@ if (Symbol.dispose) QualityHasher.prototype[Symbol.dispose] = QualityHasher.prot
512
615
 
513
616
  const imports = {
514
617
  __wbindgen_placeholder__: {
618
+ __wbg_length_6bb7e81f9d7713e4: function(arg0) {
619
+ const ret = arg0.length;
620
+ return ret;
621
+ },
622
+ __wbg_prototypesetcall_3d4a26c1ed734349: function(arg0, arg1, arg2) {
623
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
624
+ },
515
625
  __wbg_wbindgenthrow_451ec1a8469d7eb6: function(arg0, arg1) {
516
626
  throw new Error(getStringFromWasm0(arg0, arg1));
517
627
  },
Binary file
@@ -7,16 +7,19 @@ export const portablehashv1_new: (a: number, b: bigint) => number;
7
7
  export const portablehashv1_update: (a: number, b: number, c: number) => void;
8
8
  export const portablehashv1_digest: (a: number) => bigint;
9
9
  export const portablehashv1_reset: (a: number) => void;
10
+ export const hash_v1_batch: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
10
11
  export const hash_v2: (a: number, b: number, c: number, d: bigint) => bigint;
11
12
  export const __wbg_portablehashv2_free: (a: number, b: number) => void;
12
13
  export const portablehashv2_new: (a: number, b: bigint) => number;
13
14
  export const portablehashv2_update: (a: number, b: number, c: number) => void;
14
15
  export const portablehashv2_digest: (a: number) => bigint;
15
16
  export const portablehashv2_reset: (a: number) => void;
17
+ export const hash_v2_batch: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
16
18
  export const hash_v3: (a: number, b: number, c: number, d: bigint) => bigint;
17
19
  export const hash_v3_micro: (a: number, b: number, c: number, d: bigint) => bigint;
18
20
  export const hash_v3_nano: (a: number, b: number, c: number, d: bigint) => bigint;
19
21
  export const portablehashv3_digest: (a: number) => bigint;
22
+ export const hash_v3_batch: (a: number, b: number, c: number, d: bigint) => [number, number, number, number];
20
23
  export const __wbg_fasthasher_free: (a: number, b: number) => void;
21
24
  export const fasthasher_new: (a: number, b: bigint) => number;
22
25
  export const fasthasher_update: (a: number, b: number, c: number) => void;
@@ -29,21 +32,21 @@ export const fasthasher_digest: (a: number) => bigint;
29
32
  export const fasthasher_reset: (a: number) => void;
30
33
  export const qualityhasher_update: (a: number, b: number, c: number) => void;
31
34
  export const qualityhasher_digest: (a: number) => bigint;
35
+ export const fasthasher_update_u128: (a: number, b: bigint, c: bigint) => void;
36
+ export const qualityhasher_update_u128: (a: number, b: bigint, c: bigint) => void;
32
37
  export const fasthasher_update_u8: (a: number, b: number) => void;
33
38
  export const fasthasher_update_u16: (a: number, b: number) => void;
34
39
  export const qualityhasher_update_u8: (a: number, b: number) => void;
35
40
  export const qualityhasher_update_u16: (a: number, b: number) => void;
36
- export const fasthasher_update_u128: (a: number, b: bigint, c: bigint) => void;
37
- export const qualityhasher_update_u128: (a: number, b: bigint, c: bigint) => void;
41
+ export const qualityhasher_new: (a: number, b: bigint) => number;
38
42
  export const fasthasher_update_u32: (a: number, b: number) => void;
39
43
  export const fasthasher_update_u64: (a: number, b: bigint) => void;
40
44
  export const qualityhasher_update_u32: (a: number, b: number) => void;
41
45
  export const qualityhasher_update_u64: (a: number, b: bigint) => void;
42
- export const qualityhasher_new: (a: number, b: bigint) => number;
46
+ export const qualityhasher_reset: (a: number) => void;
43
47
  export const __wbg_qualityhasher_free: (a: number, b: number) => void;
44
48
  export const __wbg_portablehashv3_free: (a: number, b: number) => void;
45
49
  export const portablehashv3_reset: (a: number) => void;
46
- export const qualityhasher_reset: (a: number) => void;
47
50
  export const qualityhasher_update_i128: (a: number, b: bigint, c: bigint) => void;
48
51
  export const qualityhasher_update_i64: (a: number, b: bigint) => void;
49
52
  export const qualityhasher_update_i32: (a: number, b: number) => void;
@@ -53,4 +56,7 @@ export const portablehashv3_update: (a: number, b: number, c: number) => void;
53
56
  export const portablehashv3_new: (a: number, b: bigint) => number;
54
57
  export const __wbindgen_export_0: WebAssembly.Table;
55
58
  export const __wbindgen_malloc: (a: number, b: number) => number;
59
+ export const __externref_table_alloc: () => number;
60
+ export const __externref_table_dealloc: (a: number) => void;
61
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
56
62
  export const __wbindgen_start: () => void;
@@ -9,6 +9,10 @@
9
9
  * * `seed` - Seed value for hash (default: 0)
10
10
  */
11
11
  export function hash_v1(input: Uint8Array, seed?: bigint | null): bigint;
12
+ /**
13
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
14
+ */
15
+ export function hash_v1_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
12
16
  /**
13
17
  * Computes RapidHash V2 (64-bit) hash
14
18
  *
@@ -18,6 +22,10 @@ export function hash_v1(input: Uint8Array, seed?: bigint | null): bigint;
18
22
  * * `seed` - Seed value for hash (default: 0)
19
23
  */
20
24
  export function hash_v2(input: Uint8Array, seed?: bigint | null): bigint;
25
+ /**
26
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
27
+ */
28
+ export function hash_v2_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
21
29
  /**
22
30
  * Computes RapidHash V3 (64-bit) hash
23
31
  *
@@ -45,6 +53,10 @@ export function hash_v3_micro(input: Uint8Array, seed?: bigint | null): bigint;
45
53
  * * `seed` - Seed value for hash (default: 0)
46
54
  */
47
55
  export function hash_v3_nano(input: Uint8Array, seed?: bigint | null): bigint;
56
+ /**
57
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
58
+ */
59
+ export function hash_v3_batch(chunks: Uint8Array[], seed?: bigint | null): BigUint64Array;
48
60
  export class FastHasher {
49
61
  free(): void;
50
62
  [Symbol.dispose](): void;
@@ -15,6 +15,11 @@ function getUint8ArrayMemory0() {
15
15
  return cachedUint8ArrayMemory0;
16
16
  }
17
17
 
18
+ function getArrayU8FromWasm0(ptr, len) {
19
+ ptr = ptr >>> 0;
20
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
21
+ }
22
+
18
23
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
19
24
 
20
25
  cachedTextDecoder.decode();
@@ -58,6 +63,68 @@ export function hash_v1(input, seed) {
58
63
  return BigInt.asUintN(64, ret);
59
64
  }
60
65
 
66
+ let cachedDataViewMemory0 = null;
67
+
68
+ function getDataViewMemory0() {
69
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
70
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
71
+ }
72
+ return cachedDataViewMemory0;
73
+ }
74
+
75
+ function addToExternrefTable0(obj) {
76
+ const idx = wasm.__externref_table_alloc();
77
+ wasm.__wbindgen_export_0.set(idx, obj);
78
+ return idx;
79
+ }
80
+
81
+ function passArrayJsValueToWasm0(array, malloc) {
82
+ const ptr = malloc(array.length * 4, 4) >>> 0;
83
+ for (let i = 0; i < array.length; i++) {
84
+ const add = addToExternrefTable0(array[i]);
85
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
86
+ }
87
+ WASM_VECTOR_LEN = array.length;
88
+ return ptr;
89
+ }
90
+
91
+ function takeFromExternrefTable0(idx) {
92
+ const value = wasm.__wbindgen_export_0.get(idx);
93
+ wasm.__externref_table_dealloc(idx);
94
+ return value;
95
+ }
96
+
97
+ let cachedBigUint64ArrayMemory0 = null;
98
+
99
+ function getBigUint64ArrayMemory0() {
100
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
101
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
102
+ }
103
+ return cachedBigUint64ArrayMemory0;
104
+ }
105
+
106
+ function getArrayU64FromWasm0(ptr, len) {
107
+ ptr = ptr >>> 0;
108
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
109
+ }
110
+ /**
111
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
112
+ * @param {Uint8Array[]} chunks
113
+ * @param {bigint | null} [seed]
114
+ * @returns {BigUint64Array}
115
+ */
116
+ export function hash_v1_batch(chunks, seed) {
117
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
118
+ const len0 = WASM_VECTOR_LEN;
119
+ const ret = wasm.hash_v1_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
120
+ if (ret[3]) {
121
+ throw takeFromExternrefTable0(ret[2]);
122
+ }
123
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
124
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
125
+ return v2;
126
+ }
127
+
61
128
  /**
62
129
  * Computes RapidHash V2 (64-bit) hash
63
130
  *
@@ -76,6 +143,24 @@ export function hash_v2(input, seed) {
76
143
  return BigInt.asUintN(64, ret);
77
144
  }
78
145
 
146
+ /**
147
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
148
+ * @param {Uint8Array[]} chunks
149
+ * @param {bigint | null} [seed]
150
+ * @returns {BigUint64Array}
151
+ */
152
+ export function hash_v2_batch(chunks, seed) {
153
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
154
+ const len0 = WASM_VECTOR_LEN;
155
+ const ret = wasm.hash_v2_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
156
+ if (ret[3]) {
157
+ throw takeFromExternrefTable0(ret[2]);
158
+ }
159
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
160
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
161
+ return v2;
162
+ }
163
+
79
164
  /**
80
165
  * Computes RapidHash V3 (64-bit) hash
81
166
  *
@@ -130,6 +215,24 @@ export function hash_v3_nano(input, seed) {
130
215
  return BigInt.asUintN(64, ret);
131
216
  }
132
217
 
218
+ /**
219
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
220
+ * @param {Uint8Array[]} chunks
221
+ * @param {bigint | null} [seed]
222
+ * @returns {BigUint64Array}
223
+ */
224
+ export function hash_v3_batch(chunks, seed) {
225
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ret = wasm.hash_v3_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
228
+ if (ret[3]) {
229
+ throw takeFromExternrefTable0(ret[2]);
230
+ }
231
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
232
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
233
+ return v2;
234
+ }
235
+
133
236
  const FastHasherFinalization = (typeof FinalizationRegistry === 'undefined')
134
237
  ? { register: () => {}, unregister: () => {} }
135
238
  : new FinalizationRegistry(ptr => wasm.__wbg_fasthasher_free(ptr >>> 0, 1));
@@ -516,6 +619,15 @@ export class QualityHasher {
516
619
  }
517
620
  if (Symbol.dispose) QualityHasher.prototype[Symbol.dispose] = QualityHasher.prototype.free;
518
621
 
622
+ export function __wbg_length_6bb7e81f9d7713e4(arg0) {
623
+ const ret = arg0.length;
624
+ return ret;
625
+ };
626
+
627
+ export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
628
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
629
+ };
630
+
519
631
  export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
520
632
  throw new Error(getStringFromWasm0(arg0, arg1));
521
633
  };
Binary file