rapidhash-wasm-vn 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/bundler/rapidhash_wasm_vn.d.ts +161 -0
- package/bundler/rapidhash_wasm_vn.js +5 -0
- package/bundler/rapidhash_wasm_vn_bg.js +539 -0
- package/bundler/rapidhash_wasm_vn_bg.wasm +0 -0
- package/bundler/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
- package/deno/rapidhash_wasm_vn.d.ts +161 -0
- package/deno/rapidhash_wasm_vn.js +537 -0
- package/deno/rapidhash_wasm_vn_bg.wasm +0 -0
- package/deno/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
- package/esm/package.json +4 -0
- package/esm/rapidhash_wasm_vn.d.ts +161 -0
- package/esm/rapidhash_wasm_vn.js +17 -0
- package/esm/rapidhash_wasm_vn_bg.js +533 -0
- package/esm/rapidhash_wasm_vn_bg.wasm +0 -0
- package/esm/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
- package/module/rapidhash_wasm_vn.d.ts +161 -0
- package/module/rapidhash_wasm_vn.js +538 -0
- package/module/rapidhash_wasm_vn_bg.wasm +0 -0
- package/module/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
- package/no-modules/rapidhash_wasm_vn.d.ts +233 -0
- package/no-modules/rapidhash_wasm_vn.js +654 -0
- package/no-modules/rapidhash_wasm_vn_bg.wasm +0 -0
- package/no-modules/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
- package/nodejs/rapidhash_wasm_vn.d.ts +161 -0
- package/nodejs/rapidhash_wasm_vn.js +546 -0
- package/nodejs/rapidhash_wasm_vn_bg.wasm +0 -0
- package/nodejs/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
- package/package.json +79 -0
- package/web/rapidhash_wasm_vn.d.ts +241 -0
- package/web/rapidhash_wasm_vn.js +644 -0
- package/web/rapidhash_wasm_vn_bg.wasm +0 -0
- package/web/rapidhash_wasm_vn_bg.wasm.d.ts +56 -0
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
let wasm;
|
|
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
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
+
|
|
14
|
+
cachedTextDecoder.decode();
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let WASM_VECTOR_LEN = 0;
|
|
34
|
+
|
|
35
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
36
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
37
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
38
|
+
WASM_VECTOR_LEN = arg.length;
|
|
39
|
+
return ptr;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isLikeNone(x) {
|
|
43
|
+
return x === undefined || x === null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Computes RapidHash V1 (64-bit) hash
|
|
47
|
+
*
|
|
48
|
+
* # Arguments
|
|
49
|
+
*
|
|
50
|
+
* * `input` - Input data to hash
|
|
51
|
+
* * `seed` - Seed value for hash (default: 0)
|
|
52
|
+
* @param {Uint8Array} input
|
|
53
|
+
* @param {bigint | null} [seed]
|
|
54
|
+
* @returns {bigint}
|
|
55
|
+
*/
|
|
56
|
+
export function hash_v1(input, seed) {
|
|
57
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ret = wasm.hash_v1(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
60
|
+
return BigInt.asUintN(64, ret);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Computes RapidHash V2 (64-bit) hash
|
|
65
|
+
*
|
|
66
|
+
* # Arguments
|
|
67
|
+
*
|
|
68
|
+
* * `input` - Input data to hash
|
|
69
|
+
* * `seed` - Seed value for hash (default: 0)
|
|
70
|
+
* @param {Uint8Array} input
|
|
71
|
+
* @param {bigint | null} [seed]
|
|
72
|
+
* @returns {bigint}
|
|
73
|
+
*/
|
|
74
|
+
export function hash_v2(input, seed) {
|
|
75
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
76
|
+
const len0 = WASM_VECTOR_LEN;
|
|
77
|
+
const ret = wasm.hash_v2(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
78
|
+
return BigInt.asUintN(64, ret);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Computes RapidHash V3 (64-bit) hash
|
|
83
|
+
*
|
|
84
|
+
* # Arguments
|
|
85
|
+
*
|
|
86
|
+
* * `input` - Input data to hash
|
|
87
|
+
* * `seed` - Seed value for hash (default: 0)
|
|
88
|
+
* @param {Uint8Array} input
|
|
89
|
+
* @param {bigint | null} [seed]
|
|
90
|
+
* @returns {bigint}
|
|
91
|
+
*/
|
|
92
|
+
export function hash_v3(input, seed) {
|
|
93
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
94
|
+
const len0 = WASM_VECTOR_LEN;
|
|
95
|
+
const ret = wasm.hash_v3(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
96
|
+
return BigInt.asUintN(64, ret);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Computes RapidHash V3 (64-bit) micro hash
|
|
101
|
+
*
|
|
102
|
+
* # Arguments
|
|
103
|
+
*
|
|
104
|
+
* * `input` - Input data to hash
|
|
105
|
+
* * `seed` - Seed value for hash (default: 0)
|
|
106
|
+
* @param {Uint8Array} input
|
|
107
|
+
* @param {bigint | null} [seed]
|
|
108
|
+
* @returns {bigint}
|
|
109
|
+
*/
|
|
110
|
+
export function hash_v3_micro(input, seed) {
|
|
111
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
112
|
+
const len0 = WASM_VECTOR_LEN;
|
|
113
|
+
const ret = wasm.hash_v3_micro(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
114
|
+
return BigInt.asUintN(64, ret);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Computes RapidHash V3 (64-bit) nano hash
|
|
119
|
+
*
|
|
120
|
+
* # Arguments
|
|
121
|
+
*
|
|
122
|
+
* * `input` - Input data to hash
|
|
123
|
+
* * `seed` - Seed value for hash (default: 0)
|
|
124
|
+
* @param {Uint8Array} input
|
|
125
|
+
* @param {bigint | null} [seed]
|
|
126
|
+
* @returns {bigint}
|
|
127
|
+
*/
|
|
128
|
+
export function hash_v3_nano(input, seed) {
|
|
129
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
const ret = wasm.hash_v3_nano(ptr0, len0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
132
|
+
return BigInt.asUintN(64, ret);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const FastHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
136
|
+
? { register: () => {}, unregister: () => {} }
|
|
137
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fasthasher_free(ptr >>> 0, 1));
|
|
138
|
+
|
|
139
|
+
export class FastHasher {
|
|
140
|
+
|
|
141
|
+
__destroy_into_raw() {
|
|
142
|
+
const ptr = this.__wbg_ptr;
|
|
143
|
+
this.__wbg_ptr = 0;
|
|
144
|
+
FastHasherFinalization.unregister(this);
|
|
145
|
+
return ptr;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
free() {
|
|
149
|
+
const ptr = this.__destroy_into_raw();
|
|
150
|
+
wasm.__wbg_fasthasher_free(ptr, 0);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @param {bigint | null} [seed]
|
|
154
|
+
*/
|
|
155
|
+
constructor(seed) {
|
|
156
|
+
const ret = wasm.fasthasher_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
157
|
+
this.__wbg_ptr = ret >>> 0;
|
|
158
|
+
FastHasherFinalization.register(this, this.__wbg_ptr, this);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Updates the hash with new data
|
|
163
|
+
* @param {Uint8Array} data
|
|
164
|
+
*/
|
|
165
|
+
update(data) {
|
|
166
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
167
|
+
const len0 = WASM_VECTOR_LEN;
|
|
168
|
+
wasm.fasthasher_update(this.__wbg_ptr, ptr0, len0);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @param {number} data
|
|
172
|
+
*/
|
|
173
|
+
update_u8(data) {
|
|
174
|
+
wasm.fasthasher_update_i8(this.__wbg_ptr, data);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @param {number} data
|
|
178
|
+
*/
|
|
179
|
+
update_u16(data) {
|
|
180
|
+
wasm.fasthasher_update_i16(this.__wbg_ptr, data);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @param {number} data
|
|
184
|
+
*/
|
|
185
|
+
update_u32(data) {
|
|
186
|
+
wasm.fasthasher_update_i32(this.__wbg_ptr, data);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @param {bigint} data
|
|
190
|
+
*/
|
|
191
|
+
update_u64(data) {
|
|
192
|
+
wasm.fasthasher_update_i64(this.__wbg_ptr, data);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @param {bigint} data
|
|
196
|
+
*/
|
|
197
|
+
update_u128(data) {
|
|
198
|
+
wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @param {number} data
|
|
202
|
+
*/
|
|
203
|
+
update_i8(data) {
|
|
204
|
+
wasm.fasthasher_update_i8(this.__wbg_ptr, data);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @param {number} data
|
|
208
|
+
*/
|
|
209
|
+
update_i16(data) {
|
|
210
|
+
wasm.fasthasher_update_i16(this.__wbg_ptr, data);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* @param {number} data
|
|
214
|
+
*/
|
|
215
|
+
update_i32(data) {
|
|
216
|
+
wasm.fasthasher_update_i32(this.__wbg_ptr, data);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @param {bigint} data
|
|
220
|
+
*/
|
|
221
|
+
update_i64(data) {
|
|
222
|
+
wasm.fasthasher_update_i64(this.__wbg_ptr, data);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @param {bigint} data
|
|
226
|
+
*/
|
|
227
|
+
update_i128(data) {
|
|
228
|
+
wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Finalizes the hash and returns the result
|
|
232
|
+
* @returns {bigint}
|
|
233
|
+
*/
|
|
234
|
+
digest() {
|
|
235
|
+
const ret = wasm.fasthasher_digest(this.__wbg_ptr);
|
|
236
|
+
return BigInt.asUintN(64, ret);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Resets the hasher
|
|
240
|
+
*/
|
|
241
|
+
reset() {
|
|
242
|
+
wasm.fasthasher_reset(this.__wbg_ptr);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (Symbol.dispose) FastHasher.prototype[Symbol.dispose] = FastHasher.prototype.free;
|
|
246
|
+
|
|
247
|
+
const PortableHashV1Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
248
|
+
? { register: () => {}, unregister: () => {} }
|
|
249
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_portablehashv1_free(ptr >>> 0, 1));
|
|
250
|
+
/**
|
|
251
|
+
* Streaming PortableHashV1
|
|
252
|
+
*/
|
|
253
|
+
export class PortableHashV1 {
|
|
254
|
+
|
|
255
|
+
__destroy_into_raw() {
|
|
256
|
+
const ptr = this.__wbg_ptr;
|
|
257
|
+
this.__wbg_ptr = 0;
|
|
258
|
+
PortableHashV1Finalization.unregister(this);
|
|
259
|
+
return ptr;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
free() {
|
|
263
|
+
const ptr = this.__destroy_into_raw();
|
|
264
|
+
wasm.__wbg_portablehashv1_free(ptr, 0);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* @param {bigint | null} [seed]
|
|
268
|
+
*/
|
|
269
|
+
constructor(seed) {
|
|
270
|
+
const ret = wasm.portablehashv1_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
271
|
+
this.__wbg_ptr = ret >>> 0;
|
|
272
|
+
PortableHashV1Finalization.register(this, this.__wbg_ptr, this);
|
|
273
|
+
return this;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Updates the hash with new data
|
|
277
|
+
* @param {Uint8Array} data
|
|
278
|
+
*/
|
|
279
|
+
update(data) {
|
|
280
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
wasm.portablehashv1_update(this.__wbg_ptr, ptr0, len0);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Finalizes the hash and returns the result
|
|
286
|
+
* @returns {bigint}
|
|
287
|
+
*/
|
|
288
|
+
digest() {
|
|
289
|
+
const ret = wasm.portablehashv1_digest(this.__wbg_ptr);
|
|
290
|
+
return BigInt.asUintN(64, ret);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Resets the hasher with optional new seed
|
|
294
|
+
*/
|
|
295
|
+
reset() {
|
|
296
|
+
wasm.portablehashv1_reset(this.__wbg_ptr);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (Symbol.dispose) PortableHashV1.prototype[Symbol.dispose] = PortableHashV1.prototype.free;
|
|
300
|
+
|
|
301
|
+
const PortableHashV2Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
302
|
+
? { register: () => {}, unregister: () => {} }
|
|
303
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_portablehashv2_free(ptr >>> 0, 1));
|
|
304
|
+
/**
|
|
305
|
+
* Streaming PortableHashV2
|
|
306
|
+
*/
|
|
307
|
+
export class PortableHashV2 {
|
|
308
|
+
|
|
309
|
+
__destroy_into_raw() {
|
|
310
|
+
const ptr = this.__wbg_ptr;
|
|
311
|
+
this.__wbg_ptr = 0;
|
|
312
|
+
PortableHashV2Finalization.unregister(this);
|
|
313
|
+
return ptr;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
free() {
|
|
317
|
+
const ptr = this.__destroy_into_raw();
|
|
318
|
+
wasm.__wbg_portablehashv2_free(ptr, 0);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @param {bigint | null} [seed]
|
|
322
|
+
*/
|
|
323
|
+
constructor(seed) {
|
|
324
|
+
const ret = wasm.portablehashv2_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
325
|
+
this.__wbg_ptr = ret >>> 0;
|
|
326
|
+
PortableHashV2Finalization.register(this, this.__wbg_ptr, this);
|
|
327
|
+
return this;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Updates the hash with new data
|
|
331
|
+
* @param {Uint8Array} data
|
|
332
|
+
*/
|
|
333
|
+
update(data) {
|
|
334
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
335
|
+
const len0 = WASM_VECTOR_LEN;
|
|
336
|
+
wasm.portablehashv2_update(this.__wbg_ptr, ptr0, len0);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Finalizes the hash and returns the result
|
|
340
|
+
* @returns {bigint}
|
|
341
|
+
*/
|
|
342
|
+
digest() {
|
|
343
|
+
const ret = wasm.portablehashv2_digest(this.__wbg_ptr);
|
|
344
|
+
return BigInt.asUintN(64, ret);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Resets the hasher with optional new seed
|
|
348
|
+
*/
|
|
349
|
+
reset() {
|
|
350
|
+
wasm.portablehashv2_reset(this.__wbg_ptr);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (Symbol.dispose) PortableHashV2.prototype[Symbol.dispose] = PortableHashV2.prototype.free;
|
|
354
|
+
|
|
355
|
+
const PortableHashV3Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
356
|
+
? { register: () => {}, unregister: () => {} }
|
|
357
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_portablehashv3_free(ptr >>> 0, 1));
|
|
358
|
+
/**
|
|
359
|
+
* Streaming PortableHashV3
|
|
360
|
+
*/
|
|
361
|
+
export class PortableHashV3 {
|
|
362
|
+
|
|
363
|
+
__destroy_into_raw() {
|
|
364
|
+
const ptr = this.__wbg_ptr;
|
|
365
|
+
this.__wbg_ptr = 0;
|
|
366
|
+
PortableHashV3Finalization.unregister(this);
|
|
367
|
+
return ptr;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
free() {
|
|
371
|
+
const ptr = this.__destroy_into_raw();
|
|
372
|
+
wasm.__wbg_portablehashv3_free(ptr, 0);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* @param {bigint | null} [seed]
|
|
376
|
+
*/
|
|
377
|
+
constructor(seed) {
|
|
378
|
+
const ret = wasm.portablehashv2_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
379
|
+
this.__wbg_ptr = ret >>> 0;
|
|
380
|
+
PortableHashV3Finalization.register(this, this.__wbg_ptr, this);
|
|
381
|
+
return this;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Updates the hash with new data
|
|
385
|
+
* @param {Uint8Array} data
|
|
386
|
+
*/
|
|
387
|
+
update(data) {
|
|
388
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
390
|
+
wasm.portablehashv2_update(this.__wbg_ptr, ptr0, len0);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Finalizes the hash and returns the result
|
|
394
|
+
* @returns {bigint}
|
|
395
|
+
*/
|
|
396
|
+
digest() {
|
|
397
|
+
const ret = wasm.portablehashv3_digest(this.__wbg_ptr);
|
|
398
|
+
return BigInt.asUintN(64, ret);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Resets the hasher with optional new seed
|
|
402
|
+
*/
|
|
403
|
+
reset() {
|
|
404
|
+
wasm.portablehashv2_reset(this.__wbg_ptr);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (Symbol.dispose) PortableHashV3.prototype[Symbol.dispose] = PortableHashV3.prototype.free;
|
|
408
|
+
|
|
409
|
+
const QualityHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
410
|
+
? { register: () => {}, unregister: () => {} }
|
|
411
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_qualityhasher_free(ptr >>> 0, 1));
|
|
412
|
+
|
|
413
|
+
export class QualityHasher {
|
|
414
|
+
|
|
415
|
+
__destroy_into_raw() {
|
|
416
|
+
const ptr = this.__wbg_ptr;
|
|
417
|
+
this.__wbg_ptr = 0;
|
|
418
|
+
QualityHasherFinalization.unregister(this);
|
|
419
|
+
return ptr;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
free() {
|
|
423
|
+
const ptr = this.__destroy_into_raw();
|
|
424
|
+
wasm.__wbg_qualityhasher_free(ptr, 0);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @param {bigint | null} [seed]
|
|
428
|
+
*/
|
|
429
|
+
constructor(seed) {
|
|
430
|
+
const ret = wasm.fasthasher_new(!isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
431
|
+
this.__wbg_ptr = ret >>> 0;
|
|
432
|
+
QualityHasherFinalization.register(this, this.__wbg_ptr, this);
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Updates the hash with new data
|
|
437
|
+
* @param {Uint8Array} data
|
|
438
|
+
*/
|
|
439
|
+
update(data) {
|
|
440
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
441
|
+
const len0 = WASM_VECTOR_LEN;
|
|
442
|
+
wasm.qualityhasher_update(this.__wbg_ptr, ptr0, len0);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* @param {number} data
|
|
446
|
+
*/
|
|
447
|
+
update_u8(data) {
|
|
448
|
+
wasm.fasthasher_update_i8(this.__wbg_ptr, data);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* @param {number} data
|
|
452
|
+
*/
|
|
453
|
+
update_u16(data) {
|
|
454
|
+
wasm.fasthasher_update_i16(this.__wbg_ptr, data);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @param {number} data
|
|
458
|
+
*/
|
|
459
|
+
update_u32(data) {
|
|
460
|
+
wasm.fasthasher_update_i32(this.__wbg_ptr, data);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* @param {bigint} data
|
|
464
|
+
*/
|
|
465
|
+
update_u64(data) {
|
|
466
|
+
wasm.fasthasher_update_i64(this.__wbg_ptr, data);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* @param {bigint} data
|
|
470
|
+
*/
|
|
471
|
+
update_u128(data) {
|
|
472
|
+
wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @param {number} data
|
|
476
|
+
*/
|
|
477
|
+
update_i8(data) {
|
|
478
|
+
wasm.fasthasher_update_i8(this.__wbg_ptr, data);
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* @param {number} data
|
|
482
|
+
*/
|
|
483
|
+
update_i16(data) {
|
|
484
|
+
wasm.fasthasher_update_i16(this.__wbg_ptr, data);
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* @param {number} data
|
|
488
|
+
*/
|
|
489
|
+
update_i32(data) {
|
|
490
|
+
wasm.fasthasher_update_i32(this.__wbg_ptr, data);
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* @param {bigint} data
|
|
494
|
+
*/
|
|
495
|
+
update_i64(data) {
|
|
496
|
+
wasm.fasthasher_update_i64(this.__wbg_ptr, data);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @param {bigint} data
|
|
500
|
+
*/
|
|
501
|
+
update_i128(data) {
|
|
502
|
+
wasm.fasthasher_update_i128(this.__wbg_ptr, data, data >> BigInt(64));
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Finalizes the hash and returns the result
|
|
506
|
+
* @returns {bigint}
|
|
507
|
+
*/
|
|
508
|
+
digest() {
|
|
509
|
+
const ret = wasm.qualityhasher_digest(this.__wbg_ptr);
|
|
510
|
+
return BigInt.asUintN(64, ret);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Resets the hasher
|
|
514
|
+
*/
|
|
515
|
+
reset() {
|
|
516
|
+
wasm.fasthasher_reset(this.__wbg_ptr);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (Symbol.dispose) QualityHasher.prototype[Symbol.dispose] = QualityHasher.prototype.free;
|
|
520
|
+
|
|
521
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
522
|
+
|
|
523
|
+
async function __wbg_load(module, imports) {
|
|
524
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
525
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
526
|
+
try {
|
|
527
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
528
|
+
|
|
529
|
+
} catch (e) {
|
|
530
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
531
|
+
|
|
532
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
533
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
534
|
+
|
|
535
|
+
} else {
|
|
536
|
+
throw e;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const bytes = await module.arrayBuffer();
|
|
542
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
543
|
+
|
|
544
|
+
} else {
|
|
545
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
546
|
+
|
|
547
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
548
|
+
return { instance, module };
|
|
549
|
+
|
|
550
|
+
} else {
|
|
551
|
+
return instance;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function __wbg_get_imports() {
|
|
557
|
+
const imports = {};
|
|
558
|
+
imports.wbg = {};
|
|
559
|
+
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
560
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
561
|
+
};
|
|
562
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
563
|
+
const table = wasm.__wbindgen_export_0;
|
|
564
|
+
const offset = table.grow(4);
|
|
565
|
+
table.set(0, undefined);
|
|
566
|
+
table.set(offset + 0, undefined);
|
|
567
|
+
table.set(offset + 1, null);
|
|
568
|
+
table.set(offset + 2, true);
|
|
569
|
+
table.set(offset + 3, false);
|
|
570
|
+
;
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
return imports;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function __wbg_init_memory(imports, memory) {
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function __wbg_finalize_init(instance, module) {
|
|
581
|
+
wasm = instance.exports;
|
|
582
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
583
|
+
cachedUint8ArrayMemory0 = null;
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
wasm.__wbindgen_start();
|
|
587
|
+
return wasm;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function initSync(module) {
|
|
591
|
+
if (wasm !== undefined) return wasm;
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
if (typeof module !== 'undefined') {
|
|
595
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
596
|
+
({module} = module)
|
|
597
|
+
} else {
|
|
598
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const imports = __wbg_get_imports();
|
|
603
|
+
|
|
604
|
+
__wbg_init_memory(imports);
|
|
605
|
+
|
|
606
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
607
|
+
module = new WebAssembly.Module(module);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
611
|
+
|
|
612
|
+
return __wbg_finalize_init(instance, module);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
async function __wbg_init(module_or_path) {
|
|
616
|
+
if (wasm !== undefined) return wasm;
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
if (typeof module_or_path !== 'undefined') {
|
|
620
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
621
|
+
({module_or_path} = module_or_path)
|
|
622
|
+
} else {
|
|
623
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (typeof module_or_path === 'undefined') {
|
|
628
|
+
module_or_path = new URL('rapidhash_wasm_vn_bg.wasm', import.meta.url);
|
|
629
|
+
}
|
|
630
|
+
const imports = __wbg_get_imports();
|
|
631
|
+
|
|
632
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
633
|
+
module_or_path = fetch(module_or_path);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
__wbg_init_memory(imports);
|
|
637
|
+
|
|
638
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
639
|
+
|
|
640
|
+
return __wbg_finalize_init(instance, module);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
export { initSync };
|
|
644
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const hash_v1: (a: number, b: number, c: number, d: bigint) => bigint;
|
|
5
|
+
export const __wbg_portablehashv1_free: (a: number, b: number) => void;
|
|
6
|
+
export const portablehashv1_new: (a: number, b: bigint) => number;
|
|
7
|
+
export const portablehashv1_update: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const portablehashv1_digest: (a: number) => bigint;
|
|
9
|
+
export const portablehashv1_reset: (a: number) => void;
|
|
10
|
+
export const hash_v2: (a: number, b: number, c: number, d: bigint) => bigint;
|
|
11
|
+
export const __wbg_portablehashv2_free: (a: number, b: number) => void;
|
|
12
|
+
export const portablehashv2_new: (a: number, b: bigint) => number;
|
|
13
|
+
export const portablehashv2_update: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const portablehashv2_digest: (a: number) => bigint;
|
|
15
|
+
export const portablehashv2_reset: (a: number) => void;
|
|
16
|
+
export const hash_v3: (a: number, b: number, c: number, d: bigint) => bigint;
|
|
17
|
+
export const hash_v3_micro: (a: number, b: number, c: number, d: bigint) => bigint;
|
|
18
|
+
export const hash_v3_nano: (a: number, b: number, c: number, d: bigint) => bigint;
|
|
19
|
+
export const portablehashv3_digest: (a: number) => bigint;
|
|
20
|
+
export const __wbg_fasthasher_free: (a: number, b: number) => void;
|
|
21
|
+
export const fasthasher_new: (a: number, b: bigint) => number;
|
|
22
|
+
export const fasthasher_update: (a: number, b: number, c: number) => void;
|
|
23
|
+
export const fasthasher_update_i8: (a: number, b: number) => void;
|
|
24
|
+
export const fasthasher_update_i16: (a: number, b: number) => void;
|
|
25
|
+
export const fasthasher_update_i32: (a: number, b: number) => void;
|
|
26
|
+
export const fasthasher_update_i64: (a: number, b: bigint) => void;
|
|
27
|
+
export const fasthasher_update_i128: (a: number, b: bigint, c: bigint) => void;
|
|
28
|
+
export const fasthasher_digest: (a: number) => bigint;
|
|
29
|
+
export const fasthasher_reset: (a: number) => void;
|
|
30
|
+
export const qualityhasher_update: (a: number, b: number, c: number) => void;
|
|
31
|
+
export const qualityhasher_digest: (a: number) => bigint;
|
|
32
|
+
export const fasthasher_update_u8: (a: number, b: number) => void;
|
|
33
|
+
export const fasthasher_update_u16: (a: number, b: number) => void;
|
|
34
|
+
export const qualityhasher_update_u8: (a: number, b: number) => void;
|
|
35
|
+
export const qualityhasher_update_u16: (a: number, b: number) => void;
|
|
36
|
+
export const fasthasher_update_u128: (a: number, b: bigint, c: bigint) => void;
|
|
37
|
+
export const qualityhasher_update_u128: (a: number, b: bigint, c: bigint) => void;
|
|
38
|
+
export const fasthasher_update_u32: (a: number, b: number) => void;
|
|
39
|
+
export const fasthasher_update_u64: (a: number, b: bigint) => void;
|
|
40
|
+
export const qualityhasher_update_u32: (a: number, b: number) => void;
|
|
41
|
+
export const qualityhasher_update_u64: (a: number, b: bigint) => void;
|
|
42
|
+
export const qualityhasher_new: (a: number, b: bigint) => number;
|
|
43
|
+
export const __wbg_qualityhasher_free: (a: number, b: number) => void;
|
|
44
|
+
export const __wbg_portablehashv3_free: (a: number, b: number) => void;
|
|
45
|
+
export const portablehashv3_reset: (a: number) => void;
|
|
46
|
+
export const qualityhasher_reset: (a: number) => void;
|
|
47
|
+
export const qualityhasher_update_i128: (a: number, b: bigint, c: bigint) => void;
|
|
48
|
+
export const qualityhasher_update_i64: (a: number, b: bigint) => void;
|
|
49
|
+
export const qualityhasher_update_i32: (a: number, b: number) => void;
|
|
50
|
+
export const qualityhasher_update_i16: (a: number, b: number) => void;
|
|
51
|
+
export const qualityhasher_update_i8: (a: number, b: number) => void;
|
|
52
|
+
export const portablehashv3_update: (a: number, b: number, c: number) => void;
|
|
53
|
+
export const portablehashv3_new: (a: number, b: bigint) => number;
|
|
54
|
+
export const __wbindgen_export_0: WebAssembly.Table;
|
|
55
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
56
|
+
export const __wbindgen_start: () => void;
|