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