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