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