rapidhash-wasm-vn 1.2.0 → 1.2.1

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.
@@ -1,272 +1,24 @@
1
- import source wasmModule from "./rapidhash_wasm_vn_bg.wasm";
2
-
3
- let wasm;
4
-
5
- let cachedUint8ArrayMemory0 = null;
6
-
7
- function getUint8ArrayMemory0() {
8
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
9
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
10
- }
11
- return cachedUint8ArrayMemory0;
12
- }
13
-
14
- function getArrayU8FromWasm0(ptr, len) {
15
- ptr = ptr >>> 0;
16
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
17
- }
18
-
19
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
20
-
21
- cachedTextDecoder.decode();
22
-
23
- function decodeText(ptr, len) {
24
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
25
- }
26
-
27
- function getStringFromWasm0(ptr, len) {
28
- ptr = ptr >>> 0;
29
- return decodeText(ptr, len);
30
- }
31
-
32
- let WASM_VECTOR_LEN = 0;
33
-
34
- function passArray8ToWasm0(arg, malloc) {
35
- const ptr = malloc(arg.length * 1, 1) >>> 0;
36
- getUint8ArrayMemory0().set(arg, ptr / 1);
37
- WASM_VECTOR_LEN = arg.length;
38
- return ptr;
39
- }
40
-
41
- function isLikeNone(x) {
42
- return x === undefined || x === null;
43
- }
44
- /**
45
- * Computes RapidHash V1 (64-bit) hash
46
- *
47
- * # Arguments
48
- *
49
- * * `input` - Input data to hash
50
- * * `seed` - Seed value for hash (default: 0)
51
- * @param {Uint8Array} input
52
- * @param {bigint | null} [seed]
53
- * @returns {bigint}
54
- */
55
- export function hash_v1(input, seed) {
56
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
57
- const len0 = WASM_VECTOR_LEN;
58
- const ret = wasm.hash_v1(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
59
- return BigInt.asUintN(64, ret);
60
- }
61
-
62
- let cachedDataViewMemory0 = null;
63
-
64
- function getDataViewMemory0() {
65
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
66
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
67
- }
68
- return cachedDataViewMemory0;
69
- }
70
-
71
- function addToExternrefTable0(obj) {
72
- const idx = wasm.__externref_table_alloc();
73
- wasm.__wbindgen_export_0.set(idx, obj);
74
- return idx;
75
- }
76
-
77
- function passArrayJsValueToWasm0(array, malloc) {
78
- const ptr = malloc(array.length * 4, 4) >>> 0;
79
- for (let i = 0; i < array.length; i++) {
80
- const add = addToExternrefTable0(array[i]);
81
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
82
- }
83
- WASM_VECTOR_LEN = array.length;
84
- return ptr;
85
- }
86
-
87
- function takeFromExternrefTable0(idx) {
88
- const value = wasm.__wbindgen_export_0.get(idx);
89
- wasm.__externref_table_dealloc(idx);
90
- return value;
91
- }
92
-
93
- let cachedBigUint64ArrayMemory0 = null;
94
-
95
- function getBigUint64ArrayMemory0() {
96
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
97
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
98
- }
99
- return cachedBigUint64ArrayMemory0;
100
- }
101
-
102
- function getArrayU64FromWasm0(ptr, len) {
103
- ptr = ptr >>> 0;
104
- return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
105
- }
106
- /**
107
- * Computes multiple RapidHash V1 (64-bit) hashes in batch
108
- * @param {Uint8Array[]} chunks
109
- * @param {bigint | null} [seed]
110
- * @returns {BigUint64Array}
111
- */
112
- export function hash_v1_batch(chunks, seed) {
113
- const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
114
- const len0 = WASM_VECTOR_LEN;
115
- const ret = wasm.hash_v1_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
116
- if (ret[3]) {
117
- throw takeFromExternrefTable0(ret[2]);
118
- }
119
- var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
120
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
121
- return v2;
122
- }
123
-
124
- /**
125
- * Computes RapidHash V2 (64-bit) hash
126
- *
127
- * # Arguments
128
- *
129
- * * `input` - Input data to hash
130
- * * `seed` - Seed value for hash (default: 0)
131
- * @param {Uint8Array} input
132
- * @param {bigint | null} [seed]
133
- * @returns {bigint}
134
- */
135
- export function hash_v2(input, seed) {
136
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
137
- const len0 = WASM_VECTOR_LEN;
138
- const ret = wasm.hash_v2(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
139
- return BigInt.asUintN(64, ret);
140
- }
141
-
142
- /**
143
- * Computes multiple RapidHash V2 (64-bit) hashes in batch
144
- * @param {Uint8Array[]} chunks
145
- * @param {bigint | null} [seed]
146
- * @returns {BigUint64Array}
147
- */
148
- export function hash_v2_batch(chunks, seed) {
149
- const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
150
- const len0 = WASM_VECTOR_LEN;
151
- const ret = wasm.hash_v2_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
152
- if (ret[3]) {
153
- throw takeFromExternrefTable0(ret[2]);
154
- }
155
- var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
156
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
157
- return v2;
158
- }
159
-
160
- /**
161
- * Computes RapidHash V3 (64-bit) hash
162
- *
163
- * # Arguments
164
- *
165
- * * `input` - Input data to hash
166
- * * `seed` - Seed value for hash (default: 0)
167
- * @param {Uint8Array} input
168
- * @param {bigint | null} [seed]
169
- * @returns {bigint}
170
- */
171
- export function hash_v3(input, seed) {
172
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
173
- const len0 = WASM_VECTOR_LEN;
174
- const ret = wasm.hash_v3(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
175
- return BigInt.asUintN(64, ret);
176
- }
177
-
178
- /**
179
- * Computes RapidHash V3 (64-bit) micro hash
180
- *
181
- * # Arguments
182
- *
183
- * * `input` - Input data to hash
184
- * * `seed` - Seed value for hash (default: 0)
185
- * @param {Uint8Array} input
186
- * @param {bigint | null} [seed]
187
- * @returns {bigint}
188
- */
189
- export function hash_v3_micro(input, seed) {
190
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
191
- const len0 = WASM_VECTOR_LEN;
192
- const ret = wasm.hash_v3_micro(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
193
- return BigInt.asUintN(64, ret);
194
- }
195
-
196
- /**
197
- * Computes RapidHash V3 (64-bit) nano hash
198
- *
199
- * # Arguments
200
- *
201
- * * `input` - Input data to hash
202
- * * `seed` - Seed value for hash (default: 0)
203
- * @param {Uint8Array} input
204
- * @param {bigint | null} [seed]
205
- * @returns {bigint}
206
- */
207
- export function hash_v3_nano(input, seed) {
208
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
209
- const len0 = WASM_VECTOR_LEN;
210
- const ret = wasm.hash_v3_nano(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
211
- return BigInt.asUintN(64, ret);
212
- }
213
-
214
- /**
215
- * RapidHash V3 - (64-bit) hash file
216
- *
217
- * # Arguments
218
- *
219
- * * `input` - Input data to hash
220
- * * `seed` - Seed value for hash (default: 0)
221
- * @param {Uint8Array} input
222
- * @param {bigint | null} [seed]
223
- * @returns {bigint}
224
- */
225
- export function hash_file_v3(input, seed) {
226
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
227
- const len0 = WASM_VECTOR_LEN;
228
- const ret = wasm.hash_file_v3(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
229
- if (ret[2]) {
230
- throw takeFromExternrefTable0(ret[1]);
231
- }
232
- return BigInt.asUintN(64, ret[0]);
233
- }
234
-
235
- /**
236
- * Computes multiple RapidHash V3 (64-bit) hashes in batch
237
- * @param {Uint8Array[]} chunks
238
- * @param {bigint | null} [seed]
239
- * @returns {BigUint64Array}
240
- */
241
- export function hash_v3_batch(chunks, seed) {
242
- const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
243
- const len0 = WASM_VECTOR_LEN;
244
- const ret = wasm.hash_v3_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
245
- if (ret[3]) {
246
- throw takeFromExternrefTable0(ret[2]);
247
- }
248
- var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
249
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
250
- return v2;
251
- }
252
-
253
- const FastHasherFinalization = (typeof FinalizationRegistry === 'undefined')
254
- ? { register: () => {}, unregister: () => {} }
255
- : new FinalizationRegistry(ptr => wasm.__wbg_fasthasher_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./rapidhash_wasm_vn.d.ts" */
256
2
 
257
3
  export class FastHasher {
258
-
259
4
  __destroy_into_raw() {
260
5
  const ptr = this.__wbg_ptr;
261
6
  this.__wbg_ptr = 0;
262
7
  FastHasherFinalization.unregister(this);
263
8
  return ptr;
264
9
  }
265
-
266
10
  free() {
267
11
  const ptr = this.__destroy_into_raw();
268
12
  wasm.__wbg_fasthasher_free(ptr, 0);
269
13
  }
14
+ /**
15
+ * Finalizes the hash and returns the result
16
+ * @returns {bigint}
17
+ */
18
+ digest() {
19
+ const ret = wasm.fasthasher_digest(this.__wbg_ptr);
20
+ return BigInt.asUintN(64, ret);
21
+ }
270
22
  /**
271
23
  * @param {bigint | null} [seed]
272
24
  */
@@ -276,6 +28,12 @@ export class FastHasher {
276
28
  FastHasherFinalization.register(this, this.__wbg_ptr, this);
277
29
  return this;
278
30
  }
31
+ /**
32
+ * Resets the hasher
33
+ */
34
+ reset() {
35
+ wasm.fasthasher_reset(this.__wbg_ptr);
36
+ }
279
37
  /**
280
38
  * Updates the hash with new data
281
39
  * @param {Uint8Array} data
@@ -286,101 +44,90 @@ export class FastHasher {
286
44
  wasm.fasthasher_update(this.__wbg_ptr, ptr0, len0);
287
45
  }
288
46
  /**
289
- * @param {number} data
47
+ * @param {bigint} data
290
48
  */
291
- update_u8(data) {
292
- wasm.fasthasher_update_i8(this.__wbg_ptr, data);
49
+ update_i128(data) {
50
+ wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
293
51
  }
294
52
  /**
295
53
  * @param {number} data
296
54
  */
297
- update_u16(data) {
55
+ update_i16(data) {
298
56
  wasm.fasthasher_update_i16(this.__wbg_ptr, data);
299
57
  }
300
58
  /**
301
59
  * @param {number} data
302
60
  */
303
- update_u32(data) {
61
+ update_i32(data) {
304
62
  wasm.fasthasher_update_i32(this.__wbg_ptr, data);
305
63
  }
306
64
  /**
307
65
  * @param {bigint} data
308
66
  */
309
- update_u64(data) {
67
+ update_i64(data) {
310
68
  wasm.fasthasher_update_i64(this.__wbg_ptr, data);
311
69
  }
312
- /**
313
- * @param {bigint} data
314
- */
315
- update_u128(data) {
316
- wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
317
- }
318
70
  /**
319
71
  * @param {number} data
320
72
  */
321
73
  update_i8(data) {
322
74
  wasm.fasthasher_update_i8(this.__wbg_ptr, data);
323
75
  }
76
+ /**
77
+ * @param {bigint} data
78
+ */
79
+ update_u128(data) {
80
+ wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
81
+ }
324
82
  /**
325
83
  * @param {number} data
326
84
  */
327
- update_i16(data) {
85
+ update_u16(data) {
328
86
  wasm.fasthasher_update_i16(this.__wbg_ptr, data);
329
87
  }
330
88
  /**
331
89
  * @param {number} data
332
90
  */
333
- update_i32(data) {
91
+ update_u32(data) {
334
92
  wasm.fasthasher_update_i32(this.__wbg_ptr, data);
335
93
  }
336
94
  /**
337
95
  * @param {bigint} data
338
96
  */
339
- update_i64(data) {
97
+ update_u64(data) {
340
98
  wasm.fasthasher_update_i64(this.__wbg_ptr, data);
341
99
  }
342
100
  /**
343
- * @param {bigint} data
344
- */
345
- update_i128(data) {
346
- wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
347
- }
348
- /**
349
- * Finalizes the hash and returns the result
350
- * @returns {bigint}
351
- */
352
- digest() {
353
- const ret = wasm.fasthasher_digest(this.__wbg_ptr);
354
- return BigInt.asUintN(64, ret);
355
- }
356
- /**
357
- * Resets the hasher
101
+ * @param {number} data
358
102
  */
359
- reset() {
360
- wasm.fasthasher_reset(this.__wbg_ptr);
103
+ update_u8(data) {
104
+ wasm.fasthasher_update_i8(this.__wbg_ptr, data);
361
105
  }
362
106
  }
363
107
  if (Symbol.dispose) FastHasher.prototype[Symbol.dispose] = FastHasher.prototype.free;
364
108
 
365
- const PortableHashV1Finalization = (typeof FinalizationRegistry === 'undefined')
366
- ? { register: () => {}, unregister: () => {} }
367
- : new FinalizationRegistry(ptr => wasm.__wbg_portablehashv1_free(ptr >>> 0, 1));
368
109
  /**
369
110
  * Streaming PortableHashV1
370
111
  */
371
112
  export class PortableHashV1 {
372
-
373
113
  __destroy_into_raw() {
374
114
  const ptr = this.__wbg_ptr;
375
115
  this.__wbg_ptr = 0;
376
116
  PortableHashV1Finalization.unregister(this);
377
117
  return ptr;
378
118
  }
379
-
380
119
  free() {
381
120
  const ptr = this.__destroy_into_raw();
382
121
  wasm.__wbg_portablehashv1_free(ptr, 0);
383
122
  }
123
+ /**
124
+ * Finalizes the hash and returns the result
125
+ * @returns {bigint}
126
+ */
127
+ digest() {
128
+ const ret = wasm.portablehashv1_digest(this.__wbg_ptr);
129
+ return BigInt.asUintN(64, ret);
130
+ }
384
131
  /**
385
132
  * @param {bigint | null} [seed]
386
133
  */
@@ -390,6 +137,12 @@ export class PortableHashV1 {
390
137
  PortableHashV1Finalization.register(this, this.__wbg_ptr, this);
391
138
  return this;
392
139
  }
140
+ /**
141
+ * Resets the hasher with optional new seed
142
+ */
143
+ reset() {
144
+ wasm.portablehashv1_reset(this.__wbg_ptr);
145
+ }
393
146
  /**
394
147
  * Updates the hash with new data
395
148
  * @param {Uint8Array} data
@@ -399,42 +152,31 @@ export class PortableHashV1 {
399
152
  const len0 = WASM_VECTOR_LEN;
400
153
  wasm.portablehashv1_update(this.__wbg_ptr, ptr0, len0);
401
154
  }
402
- /**
403
- * Finalizes the hash and returns the result
404
- * @returns {bigint}
405
- */
406
- digest() {
407
- const ret = wasm.portablehashv1_digest(this.__wbg_ptr);
408
- return BigInt.asUintN(64, ret);
409
- }
410
- /**
411
- * Resets the hasher with optional new seed
412
- */
413
- reset() {
414
- wasm.portablehashv1_reset(this.__wbg_ptr);
415
- }
416
155
  }
417
156
  if (Symbol.dispose) PortableHashV1.prototype[Symbol.dispose] = PortableHashV1.prototype.free;
418
157
 
419
- const PortableHashV2Finalization = (typeof FinalizationRegistry === 'undefined')
420
- ? { register: () => {}, unregister: () => {} }
421
- : new FinalizationRegistry(ptr => wasm.__wbg_portablehashv2_free(ptr >>> 0, 1));
422
158
  /**
423
159
  * Streaming PortableHashV2
424
160
  */
425
161
  export class PortableHashV2 {
426
-
427
162
  __destroy_into_raw() {
428
163
  const ptr = this.__wbg_ptr;
429
164
  this.__wbg_ptr = 0;
430
165
  PortableHashV2Finalization.unregister(this);
431
166
  return ptr;
432
167
  }
433
-
434
168
  free() {
435
169
  const ptr = this.__destroy_into_raw();
436
170
  wasm.__wbg_portablehashv2_free(ptr, 0);
437
171
  }
172
+ /**
173
+ * Finalizes the hash and returns the result
174
+ * @returns {bigint}
175
+ */
176
+ digest() {
177
+ const ret = wasm.portablehashv2_digest(this.__wbg_ptr);
178
+ return BigInt.asUintN(64, ret);
179
+ }
438
180
  /**
439
181
  * @param {bigint | null} [seed]
440
182
  */
@@ -444,6 +186,12 @@ export class PortableHashV2 {
444
186
  PortableHashV2Finalization.register(this, this.__wbg_ptr, this);
445
187
  return this;
446
188
  }
189
+ /**
190
+ * Resets the hasher with optional new seed
191
+ */
192
+ reset() {
193
+ wasm.portablehashv2_reset(this.__wbg_ptr);
194
+ }
447
195
  /**
448
196
  * Updates the hash with new data
449
197
  * @param {Uint8Array} data
@@ -453,42 +201,31 @@ export class PortableHashV2 {
453
201
  const len0 = WASM_VECTOR_LEN;
454
202
  wasm.portablehashv2_update(this.__wbg_ptr, ptr0, len0);
455
203
  }
456
- /**
457
- * Finalizes the hash and returns the result
458
- * @returns {bigint}
459
- */
460
- digest() {
461
- const ret = wasm.portablehashv2_digest(this.__wbg_ptr);
462
- return BigInt.asUintN(64, ret);
463
- }
464
- /**
465
- * Resets the hasher with optional new seed
466
- */
467
- reset() {
468
- wasm.portablehashv2_reset(this.__wbg_ptr);
469
- }
470
204
  }
471
205
  if (Symbol.dispose) PortableHashV2.prototype[Symbol.dispose] = PortableHashV2.prototype.free;
472
206
 
473
- const PortableHashV3Finalization = (typeof FinalizationRegistry === 'undefined')
474
- ? { register: () => {}, unregister: () => {} }
475
- : new FinalizationRegistry(ptr => wasm.__wbg_portablehashv3_free(ptr >>> 0, 1));
476
207
  /**
477
208
  * Streaming PortableHashV3
478
209
  */
479
210
  export class PortableHashV3 {
480
-
481
211
  __destroy_into_raw() {
482
212
  const ptr = this.__wbg_ptr;
483
213
  this.__wbg_ptr = 0;
484
214
  PortableHashV3Finalization.unregister(this);
485
215
  return ptr;
486
216
  }
487
-
488
217
  free() {
489
218
  const ptr = this.__destroy_into_raw();
490
219
  wasm.__wbg_portablehashv3_free(ptr, 0);
491
220
  }
221
+ /**
222
+ * Finalizes the hash and returns the result
223
+ * @returns {bigint}
224
+ */
225
+ digest() {
226
+ const ret = wasm.portablehashv3_digest(this.__wbg_ptr);
227
+ return BigInt.asUintN(64, ret);
228
+ }
492
229
  /**
493
230
  * @param {bigint | null} [seed]
494
231
  */
@@ -498,6 +235,12 @@ export class PortableHashV3 {
498
235
  PortableHashV3Finalization.register(this, this.__wbg_ptr, this);
499
236
  return this;
500
237
  }
238
+ /**
239
+ * Resets the hasher with optional new seed
240
+ */
241
+ reset() {
242
+ wasm.portablehashv2_reset(this.__wbg_ptr);
243
+ }
501
244
  /**
502
245
  * Updates the hash with new data
503
246
  * @param {Uint8Array} data
@@ -507,168 +250,411 @@ export class PortableHashV3 {
507
250
  const len0 = WASM_VECTOR_LEN;
508
251
  wasm.portablehashv2_update(this.__wbg_ptr, ptr0, len0);
509
252
  }
253
+ }
254
+ if (Symbol.dispose) PortableHashV3.prototype[Symbol.dispose] = PortableHashV3.prototype.free;
255
+
256
+ export class QualityHasher {
257
+ __destroy_into_raw() {
258
+ const ptr = this.__wbg_ptr;
259
+ this.__wbg_ptr = 0;
260
+ QualityHasherFinalization.unregister(this);
261
+ return ptr;
262
+ }
263
+ free() {
264
+ const ptr = this.__destroy_into_raw();
265
+ wasm.__wbg_qualityhasher_free(ptr, 0);
266
+ }
510
267
  /**
511
268
  * Finalizes the hash and returns the result
512
269
  * @returns {bigint}
513
270
  */
514
271
  digest() {
515
- const ret = wasm.portablehashv3_digest(this.__wbg_ptr);
272
+ const ret = wasm.qualityhasher_digest(this.__wbg_ptr);
516
273
  return BigInt.asUintN(64, ret);
517
274
  }
518
275
  /**
519
- * Resets the hasher with optional new seed
276
+ * @param {bigint | null} [seed]
277
+ */
278
+ constructor(seed) {
279
+ const ret = wasm.fasthasher_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
280
+ this.__wbg_ptr = ret >>> 0;
281
+ QualityHasherFinalization.register(this, this.__wbg_ptr, this);
282
+ return this;
283
+ }
284
+ /**
285
+ * Resets the hasher
520
286
  */
521
287
  reset() {
522
- wasm.portablehashv2_reset(this.__wbg_ptr);
288
+ wasm.fasthasher_reset(this.__wbg_ptr);
289
+ }
290
+ /**
291
+ * Updates the hash with new data
292
+ * @param {Uint8Array} data
293
+ */
294
+ update(data) {
295
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
296
+ const len0 = WASM_VECTOR_LEN;
297
+ wasm.qualityhasher_update(this.__wbg_ptr, ptr0, len0);
298
+ }
299
+ /**
300
+ * @param {bigint} data
301
+ */
302
+ update_i128(data) {
303
+ wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
304
+ }
305
+ /**
306
+ * @param {number} data
307
+ */
308
+ update_i16(data) {
309
+ wasm.fasthasher_update_i16(this.__wbg_ptr, data);
310
+ }
311
+ /**
312
+ * @param {number} data
313
+ */
314
+ update_i32(data) {
315
+ wasm.fasthasher_update_i32(this.__wbg_ptr, data);
316
+ }
317
+ /**
318
+ * @param {bigint} data
319
+ */
320
+ update_i64(data) {
321
+ wasm.fasthasher_update_i64(this.__wbg_ptr, data);
322
+ }
323
+ /**
324
+ * @param {number} data
325
+ */
326
+ update_i8(data) {
327
+ wasm.fasthasher_update_i8(this.__wbg_ptr, data);
328
+ }
329
+ /**
330
+ * @param {bigint} data
331
+ */
332
+ update_u128(data) {
333
+ wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
334
+ }
335
+ /**
336
+ * @param {number} data
337
+ */
338
+ update_u16(data) {
339
+ wasm.fasthasher_update_i16(this.__wbg_ptr, data);
340
+ }
341
+ /**
342
+ * @param {number} data
343
+ */
344
+ update_u32(data) {
345
+ wasm.fasthasher_update_i32(this.__wbg_ptr, data);
346
+ }
347
+ /**
348
+ * @param {bigint} data
349
+ */
350
+ update_u64(data) {
351
+ wasm.fasthasher_update_i64(this.__wbg_ptr, data);
352
+ }
353
+ /**
354
+ * @param {number} data
355
+ */
356
+ update_u8(data) {
357
+ wasm.fasthasher_update_i8(this.__wbg_ptr, data);
358
+ }
359
+ }
360
+ if (Symbol.dispose) QualityHasher.prototype[Symbol.dispose] = QualityHasher.prototype.free;
361
+
362
+ /**
363
+ * RapidHash V3 - (64-bit) hash file
364
+ *
365
+ * # Arguments
366
+ *
367
+ * * `input` - Input data to hash
368
+ * * `seed` - Seed value for hash (default: 0)
369
+ * @param {Uint8Array} input
370
+ * @param {bigint | null} [seed]
371
+ * @returns {bigint}
372
+ */
373
+ export function hash_file_v3(input, seed) {
374
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
375
+ const len0 = WASM_VECTOR_LEN;
376
+ const ret = wasm.hash_file_v3(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
377
+ if (ret[2]) {
378
+ throw takeFromExternrefTable0(ret[1]);
379
+ }
380
+ return BigInt.asUintN(64, ret[0]);
381
+ }
382
+
383
+ /**
384
+ * Computes RapidHash V1 (64-bit) hash
385
+ *
386
+ * # Arguments
387
+ *
388
+ * * `input` - Input data to hash
389
+ * * `seed` - Seed value for hash (default: 0)
390
+ * @param {Uint8Array} input
391
+ * @param {bigint | null} [seed]
392
+ * @returns {bigint}
393
+ */
394
+ export function hash_v1(input, seed) {
395
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
396
+ const len0 = WASM_VECTOR_LEN;
397
+ const ret = wasm.hash_v1(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
398
+ return BigInt.asUintN(64, ret);
399
+ }
400
+
401
+ /**
402
+ * Computes multiple RapidHash V1 (64-bit) hashes in batch
403
+ * @param {Uint8Array[]} chunks
404
+ * @param {bigint | null} [seed]
405
+ * @returns {BigUint64Array}
406
+ */
407
+ export function hash_v1_batch(chunks, seed) {
408
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
409
+ const len0 = WASM_VECTOR_LEN;
410
+ const ret = wasm.hash_v1_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
411
+ if (ret[3]) {
412
+ throw takeFromExternrefTable0(ret[2]);
413
+ }
414
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
415
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
416
+ return v2;
417
+ }
418
+
419
+ /**
420
+ * Computes RapidHash V2 (64-bit) hash
421
+ *
422
+ * # Arguments
423
+ *
424
+ * * `input` - Input data to hash
425
+ * * `seed` - Seed value for hash (default: 0)
426
+ * @param {Uint8Array} input
427
+ * @param {bigint | null} [seed]
428
+ * @returns {bigint}
429
+ */
430
+ export function hash_v2(input, seed) {
431
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
432
+ const len0 = WASM_VECTOR_LEN;
433
+ const ret = wasm.hash_v2(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
434
+ return BigInt.asUintN(64, ret);
435
+ }
436
+
437
+ /**
438
+ * Computes multiple RapidHash V2 (64-bit) hashes in batch
439
+ * @param {Uint8Array[]} chunks
440
+ * @param {bigint | null} [seed]
441
+ * @returns {BigUint64Array}
442
+ */
443
+ export function hash_v2_batch(chunks, seed) {
444
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
445
+ const len0 = WASM_VECTOR_LEN;
446
+ const ret = wasm.hash_v2_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
447
+ if (ret[3]) {
448
+ throw takeFromExternrefTable0(ret[2]);
449
+ }
450
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
451
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
452
+ return v2;
453
+ }
454
+
455
+ /**
456
+ * Computes RapidHash V3 (64-bit) hash
457
+ *
458
+ * # Arguments
459
+ *
460
+ * * `input` - Input data to hash
461
+ * * `seed` - Seed value for hash (default: 0)
462
+ * @param {Uint8Array} input
463
+ * @param {bigint | null} [seed]
464
+ * @returns {bigint}
465
+ */
466
+ export function hash_v3(input, seed) {
467
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
468
+ const len0 = WASM_VECTOR_LEN;
469
+ const ret = wasm.hash_v3(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
470
+ return BigInt.asUintN(64, ret);
471
+ }
472
+
473
+ /**
474
+ * Computes multiple RapidHash V3 (64-bit) hashes in batch
475
+ * @param {Uint8Array[]} chunks
476
+ * @param {bigint | null} [seed]
477
+ * @returns {BigUint64Array}
478
+ */
479
+ export function hash_v3_batch(chunks, seed) {
480
+ const ptr0 = passArrayJsValueToWasm0(chunks, wasm.__wbindgen_malloc);
481
+ const len0 = WASM_VECTOR_LEN;
482
+ const ret = wasm.hash_v3_batch(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
483
+ if (ret[3]) {
484
+ throw takeFromExternrefTable0(ret[2]);
523
485
  }
486
+ var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
487
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
488
+ return v2;
524
489
  }
525
- if (Symbol.dispose) PortableHashV3.prototype[Symbol.dispose] = PortableHashV3.prototype.free;
526
-
527
- const QualityHasherFinalization = (typeof FinalizationRegistry === 'undefined')
528
- ? { register: () => {}, unregister: () => {} }
529
- : new FinalizationRegistry(ptr => wasm.__wbg_qualityhasher_free(ptr >>> 0, 1));
530
-
531
- export class QualityHasher {
532
490
 
533
- __destroy_into_raw() {
534
- const ptr = this.__wbg_ptr;
535
- this.__wbg_ptr = 0;
536
- QualityHasherFinalization.unregister(this);
537
- return ptr;
538
- }
491
+ /**
492
+ * Computes RapidHash V3 (64-bit) micro hash
493
+ *
494
+ * # Arguments
495
+ *
496
+ * * `input` - Input data to hash
497
+ * * `seed` - Seed value for hash (default: 0)
498
+ * @param {Uint8Array} input
499
+ * @param {bigint | null} [seed]
500
+ * @returns {bigint}
501
+ */
502
+ export function hash_v3_micro(input, seed) {
503
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
504
+ const len0 = WASM_VECTOR_LEN;
505
+ const ret = wasm.hash_v3_micro(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
506
+ return BigInt.asUintN(64, ret);
507
+ }
539
508
 
540
- free() {
541
- const ptr = this.__destroy_into_raw();
542
- wasm.__wbg_qualityhasher_free(ptr, 0);
543
- }
544
- /**
545
- * @param {bigint | null} [seed]
546
- */
547
- constructor(seed) {
548
- const ret = wasm.fasthasher_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
549
- this.__wbg_ptr = ret >>> 0;
550
- QualityHasherFinalization.register(this, this.__wbg_ptr, this);
551
- return this;
552
- }
553
- /**
554
- * Updates the hash with new data
555
- * @param {Uint8Array} data
556
- */
557
- update(data) {
558
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
559
- const len0 = WASM_VECTOR_LEN;
560
- wasm.qualityhasher_update(this.__wbg_ptr, ptr0, len0);
561
- }
562
- /**
563
- * @param {number} data
564
- */
565
- update_u8(data) {
566
- wasm.fasthasher_update_i8(this.__wbg_ptr, data);
567
- }
568
- /**
569
- * @param {number} data
570
- */
571
- update_u16(data) {
572
- wasm.fasthasher_update_i16(this.__wbg_ptr, data);
573
- }
574
- /**
575
- * @param {number} data
576
- */
577
- update_u32(data) {
578
- wasm.fasthasher_update_i32(this.__wbg_ptr, data);
579
- }
580
- /**
581
- * @param {bigint} data
582
- */
583
- update_u64(data) {
584
- wasm.fasthasher_update_i64(this.__wbg_ptr, data);
585
- }
586
- /**
587
- * @param {bigint} data
588
- */
589
- update_u128(data) {
590
- wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
591
- }
592
- /**
593
- * @param {number} data
594
- */
595
- update_i8(data) {
596
- wasm.fasthasher_update_i8(this.__wbg_ptr, data);
597
- }
598
- /**
599
- * @param {number} data
600
- */
601
- update_i16(data) {
602
- wasm.fasthasher_update_i16(this.__wbg_ptr, data);
603
- }
604
- /**
605
- * @param {number} data
606
- */
607
- update_i32(data) {
608
- wasm.fasthasher_update_i32(this.__wbg_ptr, data);
609
- }
610
- /**
611
- * @param {bigint} data
612
- */
613
- update_i64(data) {
614
- wasm.fasthasher_update_i64(this.__wbg_ptr, data);
615
- }
616
- /**
617
- * @param {bigint} data
618
- */
619
- update_i128(data) {
620
- wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
621
- }
622
- /**
623
- * Finalizes the hash and returns the result
624
- * @returns {bigint}
625
- */
626
- digest() {
627
- const ret = wasm.qualityhasher_digest(this.__wbg_ptr);
628
- return BigInt.asUintN(64, ret);
629
- }
630
- /**
631
- * Resets the hasher
632
- */
633
- reset() {
634
- wasm.fasthasher_reset(this.__wbg_ptr);
635
- }
509
+ /**
510
+ * Computes RapidHash V3 (64-bit) nano hash
511
+ *
512
+ * # Arguments
513
+ *
514
+ * * `input` - Input data to hash
515
+ * * `seed` - Seed value for hash (default: 0)
516
+ * @param {Uint8Array} input
517
+ * @param {bigint | null} [seed]
518
+ * @returns {bigint}
519
+ */
520
+ export function hash_v3_nano(input, seed) {
521
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
522
+ const len0 = WASM_VECTOR_LEN;
523
+ const ret = wasm.hash_v3_nano(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
524
+ return BigInt.asUintN(64, ret);
636
525
  }
637
- if (Symbol.dispose) QualityHasher.prototype[Symbol.dispose] = QualityHasher.prototype.free;
638
526
 
639
- const imports = {
640
- __wbindgen_placeholder__: {
641
- __wbg_length_6bb7e81f9d7713e4: function(arg0) {
527
+ function __wbg_get_imports() {
528
+ const import0 = {
529
+ __proto__: null,
530
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
531
+ throw new Error(getStringFromWasm0(arg0, arg1));
532
+ },
533
+ __wbg_length_32ed9a279acd054c: function(arg0) {
642
534
  const ret = arg0.length;
643
535
  return ret;
644
536
  },
645
- __wbg_prototypesetcall_3d4a26c1ed734349: function(arg0, arg1, arg2) {
537
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
646
538
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
647
539
  },
648
- __wbg_wbindgenthrow_451ec1a8469d7eb6: function(arg0, arg1) {
649
- throw new Error(getStringFromWasm0(arg0, arg1));
650
- },
651
- __wbindgen_cast_2241b6af4c4b2941: function(arg0, arg1) {
540
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
652
541
  // Cast intrinsic for `Ref(String) -> Externref`.
653
542
  const ret = getStringFromWasm0(arg0, arg1);
654
543
  return ret;
655
544
  },
656
545
  __wbindgen_init_externref_table: function() {
657
- const table = wasm.__wbindgen_export_0;
546
+ const table = wasm.__wbindgen_externrefs;
658
547
  const offset = table.grow(4);
659
548
  table.set(0, undefined);
660
549
  table.set(offset + 0, undefined);
661
550
  table.set(offset + 1, null);
662
551
  table.set(offset + 2, true);
663
552
  table.set(offset + 3, false);
664
- ;
665
553
  },
666
- },
554
+ };
555
+ return {
556
+ __proto__: null,
557
+ "./rapidhash_wasm_vn_bg.js": import0,
558
+ };
559
+ }
560
+
561
+ const FastHasherFinalization = (typeof FinalizationRegistry === 'undefined')
562
+ ? { register: () => {}, unregister: () => {} }
563
+ : new FinalizationRegistry(ptr => wasm.__wbg_fasthasher_free(ptr >>> 0, 1));
564
+ const PortableHashV1Finalization = (typeof FinalizationRegistry === 'undefined')
565
+ ? { register: () => {}, unregister: () => {} }
566
+ : new FinalizationRegistry(ptr => wasm.__wbg_portablehashv1_free(ptr >>> 0, 1));
567
+ const PortableHashV2Finalization = (typeof FinalizationRegistry === 'undefined')
568
+ ? { register: () => {}, unregister: () => {} }
569
+ : new FinalizationRegistry(ptr => wasm.__wbg_portablehashv2_free(ptr >>> 0, 1));
570
+ const PortableHashV3Finalization = (typeof FinalizationRegistry === 'undefined')
571
+ ? { register: () => {}, unregister: () => {} }
572
+ : new FinalizationRegistry(ptr => wasm.__wbg_portablehashv3_free(ptr >>> 0, 1));
573
+ const QualityHasherFinalization = (typeof FinalizationRegistry === 'undefined')
574
+ ? { register: () => {}, unregister: () => {} }
575
+ : new FinalizationRegistry(ptr => wasm.__wbg_qualityhasher_free(ptr >>> 0, 1));
576
+
577
+ function addToExternrefTable0(obj) {
578
+ const idx = wasm.__externref_table_alloc();
579
+ wasm.__wbindgen_externrefs.set(idx, obj);
580
+ return idx;
581
+ }
667
582
 
668
- };
583
+ function getArrayU64FromWasm0(ptr, len) {
584
+ ptr = ptr >>> 0;
585
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
586
+ }
669
587
 
670
- const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
671
- wasm = wasmInstance.exports;
588
+ function getArrayU8FromWasm0(ptr, len) {
589
+ ptr = ptr >>> 0;
590
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
591
+ }
672
592
 
673
- wasm.__wbindgen_start();
593
+ let cachedBigUint64ArrayMemory0 = null;
594
+ function getBigUint64ArrayMemory0() {
595
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
596
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
597
+ }
598
+ return cachedBigUint64ArrayMemory0;
599
+ }
600
+
601
+ let cachedDataViewMemory0 = null;
602
+ function getDataViewMemory0() {
603
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
604
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
605
+ }
606
+ return cachedDataViewMemory0;
607
+ }
608
+
609
+ function getStringFromWasm0(ptr, len) {
610
+ ptr = ptr >>> 0;
611
+ return decodeText(ptr, len);
612
+ }
613
+
614
+ let cachedUint8ArrayMemory0 = null;
615
+ function getUint8ArrayMemory0() {
616
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
617
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
618
+ }
619
+ return cachedUint8ArrayMemory0;
620
+ }
621
+
622
+ function isLikeNone(x) {
623
+ return x === undefined || x === null;
624
+ }
674
625
 
626
+ function passArray8ToWasm0(arg, malloc) {
627
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
628
+ getUint8ArrayMemory0().set(arg, ptr / 1);
629
+ WASM_VECTOR_LEN = arg.length;
630
+ return ptr;
631
+ }
632
+
633
+ function passArrayJsValueToWasm0(array, malloc) {
634
+ const ptr = malloc(array.length * 4, 4) >>> 0;
635
+ for (let i = 0; i < array.length; i++) {
636
+ const add = addToExternrefTable0(array[i]);
637
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
638
+ }
639
+ WASM_VECTOR_LEN = array.length;
640
+ return ptr;
641
+ }
642
+
643
+ function takeFromExternrefTable0(idx) {
644
+ const value = wasm.__wbindgen_externrefs.get(idx);
645
+ wasm.__externref_table_dealloc(idx);
646
+ return value;
647
+ }
648
+
649
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
650
+ cachedTextDecoder.decode();
651
+ function decodeText(ptr, len) {
652
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
653
+ }
654
+
655
+ let WASM_VECTOR_LEN = 0;
656
+
657
+ import source wasmModule from "./rapidhash_wasm_vn_bg.wasm";
658
+ const wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
659
+ let wasm = wasmInstance.exports;
660
+ wasm.__wbindgen_start();