@peerbit/riblt 1.0.2 → 1.0.3-e5f6c17

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/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Intersubjective
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # riblt-rust
2
+ Rust port of [RIBLT library](https://github.com/yangl1996/riblt) by yang1996.
3
+
4
+ Implementation of Rateless Invertible Bloom Lookup Tables (Rateless IBLTs), as
5
+ proposed in paper Practical Rateless Set Reconciliation by Lei Yang, Yossi
6
+ Gilad, and Mohammad Alizadeh. Preprint available at
7
+ [arxiv.org/abs/2402.02668](https://arxiv.org/abs/2402.02668).
8
+
9
+ ## Library API
10
+
11
+ To use this library, implement a `Symbol` trait, and create `Encoder` or `Decoder` objects to encode and decode symbols.
12
+
13
+ ### `Symbol` trait
14
+ - `fn zero() -> Self` - Create a zero symbol.
15
+ - `fn xor(&self, other: &Self) -> Self` - XOR of this symbol and another symbol.
16
+ - `fn hash(&self) -> u64` - Calculate a hash of the symbol.
17
+
18
+ Example implementation for 64-bit integer symbols:
19
+ ```rs
20
+ use riblt::*;
21
+ use std::hash::{SipHasher, Hasher};
22
+
23
+ pub type MyU64 = u64;
24
+
25
+ impl Symbol for MyU64 {
26
+ fn zero() -> MyU64 {
27
+ return 0;
28
+ }
29
+
30
+ fn xor(&self, other: &MyU64) -> MyU64 {
31
+ return self ^ other;
32
+ }
33
+
34
+ fn hash(&self) -> u64 {
35
+ let mut hasher = SipHasher::new_with_keys(123, 456);
36
+ hasher.write_u64(*self);
37
+ return hasher.finish();
38
+ }
39
+ }
40
+ ```
41
+
42
+ ### `Encoder` methods
43
+ - `Encoder::<T>::new()` - Create a new Encoder for symbols of type `T`.
44
+ - `enc.reset()` - Reset the Encoder state.
45
+ - `enc.add_symbol(symbol: &T)` - Add a new symbol to the Encoder.
46
+ - `enc.produce_next_coded_symbol() -> CodedSymbol<T>` - Produce the next coded symbol that can be decoded by the Decoder.
47
+
48
+ #### Example usage
49
+ ```rs
50
+ use riblt::*;
51
+
52
+ fn foo() {
53
+ let mut enc = Encoder::<MyU64>::new();
54
+ let symbols : [MyU64; 5] = [ 1, 2, 3, 4, 5 ];
55
+ for x in symbols {
56
+ enc.add_symbol(&x);
57
+ }
58
+
59
+ let coded = enc.produce_next_coded_symbol();
60
+
61
+ // send symbol to the decoder...
62
+ }
63
+ ```
64
+
65
+ ### `Decoder` methods
66
+ - `Decoder::<T>::new()` - Create a new Decoder for symbols of type `T`.
67
+ - `dec.reset()` - Reset the Decoder state.
68
+ - `dec.add_symbol(symbol: &T)` - Add a new symbol to the Decoder.
69
+ - `dec.add_coded_symbol(symbol: &CodedSymbol<T>)` - Add a new coded symbol to the Decoder.
70
+ - `dec.try_decode()` - Try to decode added symbols. May returns `Err(InvalidDegree)`.
71
+ - `dec.decoded()` - Returns `true` if all added coded symbols where decoded.
72
+ - `dec.get_remote_symbols() -> Vec<HashedSymbol<T>>` - Returns an array of decoded remote symbols.
73
+ - `dec.get_local_symbols() -> Vec<HashedSymbol<T>>` - Returns an array of local symbols.
74
+
75
+ Remote and local symbols can be accessed directly via Decoder properties:
76
+ - `dec.remote.symbols`,
77
+ - `dec.local.symbols`.
78
+
79
+ #### Example usage
80
+ ```rs
81
+ use riblt::*;
82
+
83
+ fn foo() {
84
+ let symbols : [CodedSymbol<MyU64>; 5] = ...;
85
+
86
+ let mut dec = Decoder::<MyU64>::new();
87
+ for i in 0..symbols.len() {
88
+ dec.add_coded_symbol(&symbols[i]);
89
+ }
90
+
91
+ if dec.try_decode().is_err() {
92
+ // Decoding error...
93
+ }
94
+
95
+ if dec.decoded() {
96
+ // Success...
97
+ }
98
+ }
99
+ ```
100
+
101
+ For the complete example see test `example` in `src/tests.rs`.
@@ -0,0 +1,72 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export class DecoderWrapper {
4
+ free(): void;
5
+ constructor();
6
+ add_symbol(symbol: bigint): void;
7
+ add_coded_symbol(coded_symbol_js: any): void;
8
+ try_decode(): void;
9
+ decoded(): boolean;
10
+ get_remote_symbols(): Array<any>;
11
+ get_local_symbols(): Array<any>;
12
+ reset(): void;
13
+ }
14
+ export class EncoderWrapper {
15
+ free(): void;
16
+ constructor();
17
+ add_symbol(symbol: bigint): void;
18
+ produce_next_coded_symbol(): any;
19
+ reset(): void;
20
+ to_decoder(): DecoderWrapper;
21
+ clone(): EncoderWrapper;
22
+ }
23
+
24
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
25
+
26
+ export interface InitOutput {
27
+ readonly memory: WebAssembly.Memory;
28
+ readonly __wbg_encoderwrapper_free: (a: number, b: number) => void;
29
+ readonly encoderwrapper_new: () => number;
30
+ readonly encoderwrapper_add_symbol: (a: number, b: bigint) => void;
31
+ readonly encoderwrapper_produce_next_coded_symbol: (a: number) => any;
32
+ readonly encoderwrapper_reset: (a: number) => void;
33
+ readonly encoderwrapper_to_decoder: (a: number) => number;
34
+ readonly encoderwrapper_clone: (a: number) => number;
35
+ readonly __wbg_decoderwrapper_free: (a: number, b: number) => void;
36
+ readonly decoderwrapper_new: () => number;
37
+ readonly decoderwrapper_add_symbol: (a: number, b: bigint) => void;
38
+ readonly decoderwrapper_add_coded_symbol: (a: number, b: any) => void;
39
+ readonly decoderwrapper_try_decode: (a: number) => [number, number];
40
+ readonly decoderwrapper_decoded: (a: number) => number;
41
+ readonly decoderwrapper_get_remote_symbols: (a: number) => any;
42
+ readonly decoderwrapper_get_local_symbols: (a: number) => any;
43
+ readonly decoderwrapper_reset: (a: number) => void;
44
+ readonly __wbindgen_exn_store: (a: number) => void;
45
+ readonly __externref_table_alloc: () => number;
46
+ readonly __wbindgen_export_2: WebAssembly.Table;
47
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
48
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
49
+ readonly __externref_table_dealloc: (a: number) => void;
50
+ readonly __wbindgen_start: () => void;
51
+ }
52
+
53
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
54
+ /**
55
+ * Instantiates the given `module`, which can either be bytes or
56
+ * a precompiled `WebAssembly.Module`.
57
+ *
58
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
59
+ *
60
+ * @returns {InitOutput}
61
+ */
62
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
63
+
64
+ /**
65
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
66
+ * for everything else, calls `WebAssembly.instantiate` directly.
67
+ *
68
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
69
+ *
70
+ * @returns {Promise<InitOutput>}
71
+ */
72
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/dist/index.js ADDED
@@ -0,0 +1,483 @@
1
+ let wasm;
2
+
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_export_2.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function handleError(f, args) {
10
+ try {
11
+ return f.apply(this, args);
12
+ } catch (e) {
13
+ const idx = addToExternrefTable0(e);
14
+ wasm.__wbindgen_exn_store(idx);
15
+ }
16
+ }
17
+
18
+ function isLikeNone(x) {
19
+ return x === undefined || x === null;
20
+ }
21
+
22
+ let cachedDataViewMemory0 = null;
23
+
24
+ function getDataViewMemory0() {
25
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
26
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
27
+ }
28
+ return cachedDataViewMemory0;
29
+ }
30
+
31
+ function debugString(val) {
32
+ // primitive types
33
+ const type = typeof val;
34
+ if (type == 'number' || type == 'boolean' || val == null) {
35
+ return `${val}`;
36
+ }
37
+ if (type == 'string') {
38
+ return `"${val}"`;
39
+ }
40
+ if (type == 'symbol') {
41
+ const description = val.description;
42
+ if (description == null) {
43
+ return 'Symbol';
44
+ } else {
45
+ return `Symbol(${description})`;
46
+ }
47
+ }
48
+ if (type == 'function') {
49
+ const name = val.name;
50
+ if (typeof name == 'string' && name.length > 0) {
51
+ return `Function(${name})`;
52
+ } else {
53
+ return 'Function';
54
+ }
55
+ }
56
+ // objects
57
+ if (Array.isArray(val)) {
58
+ const length = val.length;
59
+ let debug = '[';
60
+ if (length > 0) {
61
+ debug += debugString(val[0]);
62
+ }
63
+ for(let i = 1; i < length; i++) {
64
+ debug += ', ' + debugString(val[i]);
65
+ }
66
+ debug += ']';
67
+ return debug;
68
+ }
69
+ // Test for built-in
70
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
71
+ let className;
72
+ if (builtInMatches && builtInMatches.length > 1) {
73
+ className = builtInMatches[1];
74
+ } else {
75
+ // Failed to match the standard '[object ClassName]'
76
+ return toString.call(val);
77
+ }
78
+ if (className == 'Object') {
79
+ // we're a user defined class or Object
80
+ // JSON.stringify avoids problems with cycles, and is generally much
81
+ // easier than looping through ownProperties of `val`.
82
+ try {
83
+ return 'Object(' + JSON.stringify(val) + ')';
84
+ } catch (_) {
85
+ return 'Object';
86
+ }
87
+ }
88
+ // errors
89
+ if (val instanceof Error) {
90
+ return `${val.name}: ${val.message}\n${val.stack}`;
91
+ }
92
+ // TODO we could test for more things here, like `Set`s and `Map`s.
93
+ return className;
94
+ }
95
+
96
+ let WASM_VECTOR_LEN = 0;
97
+
98
+ let cachedUint8ArrayMemory0 = null;
99
+
100
+ function getUint8ArrayMemory0() {
101
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
102
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
103
+ }
104
+ return cachedUint8ArrayMemory0;
105
+ }
106
+
107
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
108
+
109
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
110
+ ? function (arg, view) {
111
+ return cachedTextEncoder.encodeInto(arg, view);
112
+ }
113
+ : function (arg, view) {
114
+ const buf = cachedTextEncoder.encode(arg);
115
+ view.set(buf);
116
+ return {
117
+ read: arg.length,
118
+ written: buf.length
119
+ };
120
+ });
121
+
122
+ function passStringToWasm0(arg, malloc, realloc) {
123
+
124
+ if (realloc === undefined) {
125
+ const buf = cachedTextEncoder.encode(arg);
126
+ const ptr = malloc(buf.length, 1) >>> 0;
127
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
128
+ WASM_VECTOR_LEN = buf.length;
129
+ return ptr;
130
+ }
131
+
132
+ let len = arg.length;
133
+ let ptr = malloc(len, 1) >>> 0;
134
+
135
+ const mem = getUint8ArrayMemory0();
136
+
137
+ let offset = 0;
138
+
139
+ for (; offset < len; offset++) {
140
+ const code = arg.charCodeAt(offset);
141
+ if (code > 0x7F) break;
142
+ mem[ptr + offset] = code;
143
+ }
144
+
145
+ if (offset !== len) {
146
+ if (offset !== 0) {
147
+ arg = arg.slice(offset);
148
+ }
149
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
150
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
151
+ const ret = encodeString(arg, view);
152
+
153
+ offset += ret.written;
154
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
155
+ }
156
+
157
+ WASM_VECTOR_LEN = offset;
158
+ return ptr;
159
+ }
160
+
161
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
162
+
163
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
164
+
165
+ function getStringFromWasm0(ptr, len) {
166
+ ptr = ptr >>> 0;
167
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
168
+ }
169
+
170
+ function takeFromExternrefTable0(idx) {
171
+ const value = wasm.__wbindgen_export_2.get(idx);
172
+ wasm.__externref_table_dealloc(idx);
173
+ return value;
174
+ }
175
+
176
+ const DecoderWrapperFinalization = (typeof FinalizationRegistry === 'undefined')
177
+ ? { register: () => {}, unregister: () => {} }
178
+ : new FinalizationRegistry(ptr => wasm.__wbg_decoderwrapper_free(ptr >>> 0, 1));
179
+
180
+ export class DecoderWrapper {
181
+
182
+ static __wrap(ptr) {
183
+ ptr = ptr >>> 0;
184
+ const obj = Object.create(DecoderWrapper.prototype);
185
+ obj.__wbg_ptr = ptr;
186
+ DecoderWrapperFinalization.register(obj, obj.__wbg_ptr, obj);
187
+ return obj;
188
+ }
189
+
190
+ __destroy_into_raw() {
191
+ const ptr = this.__wbg_ptr;
192
+ this.__wbg_ptr = 0;
193
+ DecoderWrapperFinalization.unregister(this);
194
+ return ptr;
195
+ }
196
+
197
+ free() {
198
+ const ptr = this.__destroy_into_raw();
199
+ wasm.__wbg_decoderwrapper_free(ptr, 0);
200
+ }
201
+ constructor() {
202
+ const ret = wasm.decoderwrapper_new();
203
+ this.__wbg_ptr = ret >>> 0;
204
+ DecoderWrapperFinalization.register(this, this.__wbg_ptr, this);
205
+ return this;
206
+ }
207
+ /**
208
+ * @param {bigint} symbol
209
+ */
210
+ add_symbol(symbol) {
211
+ wasm.decoderwrapper_add_symbol(this.__wbg_ptr, symbol);
212
+ }
213
+ /**
214
+ * @param {any} coded_symbol_js
215
+ */
216
+ add_coded_symbol(coded_symbol_js) {
217
+ wasm.decoderwrapper_add_coded_symbol(this.__wbg_ptr, coded_symbol_js);
218
+ }
219
+ try_decode() {
220
+ const ret = wasm.decoderwrapper_try_decode(this.__wbg_ptr);
221
+ if (ret[1]) {
222
+ throw takeFromExternrefTable0(ret[0]);
223
+ }
224
+ }
225
+ /**
226
+ * @returns {boolean}
227
+ */
228
+ decoded() {
229
+ const ret = wasm.decoderwrapper_decoded(this.__wbg_ptr);
230
+ return ret !== 0;
231
+ }
232
+ /**
233
+ * @returns {Array<any>}
234
+ */
235
+ get_remote_symbols() {
236
+ const ret = wasm.decoderwrapper_get_remote_symbols(this.__wbg_ptr);
237
+ return ret;
238
+ }
239
+ /**
240
+ * @returns {Array<any>}
241
+ */
242
+ get_local_symbols() {
243
+ const ret = wasm.decoderwrapper_get_local_symbols(this.__wbg_ptr);
244
+ return ret;
245
+ }
246
+ reset() {
247
+ wasm.decoderwrapper_reset(this.__wbg_ptr);
248
+ }
249
+ }
250
+
251
+ const EncoderWrapperFinalization = (typeof FinalizationRegistry === 'undefined')
252
+ ? { register: () => {}, unregister: () => {} }
253
+ : new FinalizationRegistry(ptr => wasm.__wbg_encoderwrapper_free(ptr >>> 0, 1));
254
+
255
+ export class EncoderWrapper {
256
+
257
+ static __wrap(ptr) {
258
+ ptr = ptr >>> 0;
259
+ const obj = Object.create(EncoderWrapper.prototype);
260
+ obj.__wbg_ptr = ptr;
261
+ EncoderWrapperFinalization.register(obj, obj.__wbg_ptr, obj);
262
+ return obj;
263
+ }
264
+
265
+ __destroy_into_raw() {
266
+ const ptr = this.__wbg_ptr;
267
+ this.__wbg_ptr = 0;
268
+ EncoderWrapperFinalization.unregister(this);
269
+ return ptr;
270
+ }
271
+
272
+ free() {
273
+ const ptr = this.__destroy_into_raw();
274
+ wasm.__wbg_encoderwrapper_free(ptr, 0);
275
+ }
276
+ constructor() {
277
+ const ret = wasm.encoderwrapper_new();
278
+ this.__wbg_ptr = ret >>> 0;
279
+ EncoderWrapperFinalization.register(this, this.__wbg_ptr, this);
280
+ return this;
281
+ }
282
+ /**
283
+ * @param {bigint} symbol
284
+ */
285
+ add_symbol(symbol) {
286
+ wasm.encoderwrapper_add_symbol(this.__wbg_ptr, symbol);
287
+ }
288
+ /**
289
+ * @returns {any}
290
+ */
291
+ produce_next_coded_symbol() {
292
+ const ret = wasm.encoderwrapper_produce_next_coded_symbol(this.__wbg_ptr);
293
+ return ret;
294
+ }
295
+ reset() {
296
+ wasm.encoderwrapper_reset(this.__wbg_ptr);
297
+ }
298
+ /**
299
+ * @returns {DecoderWrapper}
300
+ */
301
+ to_decoder() {
302
+ const ret = wasm.encoderwrapper_to_decoder(this.__wbg_ptr);
303
+ return DecoderWrapper.__wrap(ret);
304
+ }
305
+ /**
306
+ * @returns {EncoderWrapper}
307
+ */
308
+ clone() {
309
+ const ret = wasm.encoderwrapper_clone(this.__wbg_ptr);
310
+ return EncoderWrapper.__wrap(ret);
311
+ }
312
+ }
313
+
314
+ async function __wbg_load(module, imports) {
315
+ if (typeof Response === 'function' && module instanceof Response) {
316
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
317
+ try {
318
+ return await WebAssembly.instantiateStreaming(module, imports);
319
+
320
+ } catch (e) {
321
+ if (module.headers.get('Content-Type') != 'application/wasm') {
322
+ 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);
323
+
324
+ } else {
325
+ throw e;
326
+ }
327
+ }
328
+ }
329
+
330
+ const bytes = await module.arrayBuffer();
331
+ return await WebAssembly.instantiate(bytes, imports);
332
+
333
+ } else {
334
+ const instance = await WebAssembly.instantiate(module, imports);
335
+
336
+ if (instance instanceof WebAssembly.Instance) {
337
+ return { instance, module };
338
+
339
+ } else {
340
+ return instance;
341
+ }
342
+ }
343
+ }
344
+
345
+ function __wbg_get_imports() {
346
+ const imports = {};
347
+ imports.wbg = {};
348
+ imports.wbg.__wbg_get_bbccf8970793c087 = function() { return handleError(function (arg0, arg1) {
349
+ const ret = Reflect.get(arg0, arg1);
350
+ return ret;
351
+ }, arguments) };
352
+ imports.wbg.__wbg_new_254fa9eac11932ae = function() {
353
+ const ret = new Array();
354
+ return ret;
355
+ };
356
+ imports.wbg.__wbg_new_688846f374351c92 = function() {
357
+ const ret = new Object();
358
+ return ret;
359
+ };
360
+ imports.wbg.__wbg_push_6edad0df4b546b2c = function(arg0, arg1) {
361
+ const ret = arg0.push(arg1);
362
+ return ret;
363
+ };
364
+ imports.wbg.__wbg_set_4e647025551483bd = function() { return handleError(function (arg0, arg1, arg2) {
365
+ const ret = Reflect.set(arg0, arg1, arg2);
366
+ return ret;
367
+ }, arguments) };
368
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
369
+ const ret = arg0;
370
+ return ret;
371
+ };
372
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
373
+ const ret = BigInt.asUintN(64, arg0);
374
+ return ret;
375
+ };
376
+ imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
377
+ const v = arg1;
378
+ const ret = typeof(v) === 'bigint' ? v : undefined;
379
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
380
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
381
+ };
382
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
383
+ const ret = debugString(arg1);
384
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
385
+ const len1 = WASM_VECTOR_LEN;
386
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
387
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
388
+ };
389
+ imports.wbg.__wbindgen_init_externref_table = function() {
390
+ const table = wasm.__wbindgen_export_2;
391
+ const offset = table.grow(4);
392
+ table.set(0, undefined);
393
+ table.set(offset + 0, undefined);
394
+ table.set(offset + 1, null);
395
+ table.set(offset + 2, true);
396
+ table.set(offset + 3, false);
397
+ ;
398
+ };
399
+ imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
400
+ const ret = arg0 === arg1;
401
+ return ret;
402
+ };
403
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
404
+ const ret = getStringFromWasm0(arg0, arg1);
405
+ return ret;
406
+ };
407
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
408
+ throw new Error(getStringFromWasm0(arg0, arg1));
409
+ };
410
+
411
+ return imports;
412
+ }
413
+
414
+ function __wbg_init_memory(imports, memory) {
415
+
416
+ }
417
+
418
+ function __wbg_finalize_init(instance, module) {
419
+ wasm = instance.exports;
420
+ __wbg_init.__wbindgen_wasm_module = module;
421
+ cachedDataViewMemory0 = null;
422
+ cachedUint8ArrayMemory0 = null;
423
+
424
+
425
+ wasm.__wbindgen_start();
426
+ return wasm;
427
+ }
428
+
429
+ function initSync(module) {
430
+ if (wasm !== undefined) return wasm;
431
+
432
+
433
+ if (typeof module !== 'undefined') {
434
+ if (Object.getPrototypeOf(module) === Object.prototype) {
435
+ ({module} = module)
436
+ } else {
437
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
438
+ }
439
+ }
440
+
441
+ const imports = __wbg_get_imports();
442
+
443
+ __wbg_init_memory(imports);
444
+
445
+ if (!(module instanceof WebAssembly.Module)) {
446
+ module = new WebAssembly.Module(module);
447
+ }
448
+
449
+ const instance = new WebAssembly.Instance(module, imports);
450
+
451
+ return __wbg_finalize_init(instance, module);
452
+ }
453
+
454
+ async function __wbg_init(module_or_path) {
455
+ if (wasm !== undefined) return wasm;
456
+
457
+
458
+ if (typeof module_or_path !== 'undefined') {
459
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
460
+ ({module_or_path} = module_or_path)
461
+ } else {
462
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
463
+ }
464
+ }
465
+
466
+ if (typeof module_or_path === 'undefined') {
467
+ module_or_path = new URL('index_bg.wasm', import.meta.url);
468
+ }
469
+ const imports = __wbg_get_imports();
470
+
471
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
472
+ module_or_path = fetch(module_or_path);
473
+ }
474
+
475
+ __wbg_init_memory(imports);
476
+
477
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
478
+
479
+ return __wbg_finalize_init(instance, module);
480
+ }
481
+
482
+ export { initSync };
483
+ export default __wbg_init;
Binary file
@@ -0,0 +1,26 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_encoderwrapper_free: (a: number, b: number) => void;
5
+ export const encoderwrapper_new: () => number;
6
+ export const encoderwrapper_add_symbol: (a: number, b: bigint) => void;
7
+ export const encoderwrapper_produce_next_coded_symbol: (a: number) => any;
8
+ export const encoderwrapper_reset: (a: number) => void;
9
+ export const encoderwrapper_to_decoder: (a: number) => number;
10
+ export const encoderwrapper_clone: (a: number) => number;
11
+ export const __wbg_decoderwrapper_free: (a: number, b: number) => void;
12
+ export const decoderwrapper_new: () => number;
13
+ export const decoderwrapper_add_symbol: (a: number, b: bigint) => void;
14
+ export const decoderwrapper_add_coded_symbol: (a: number, b: any) => void;
15
+ export const decoderwrapper_try_decode: (a: number) => [number, number];
16
+ export const decoderwrapper_decoded: (a: number) => number;
17
+ export const decoderwrapper_get_remote_symbols: (a: number) => any;
18
+ export const decoderwrapper_get_local_symbols: (a: number) => any;
19
+ export const decoderwrapper_reset: (a: number) => void;
20
+ export const __wbindgen_exn_store: (a: number) => void;
21
+ export const __externref_table_alloc: () => number;
22
+ export const __wbindgen_export_2: WebAssembly.Table;
23
+ export const __wbindgen_malloc: (a: number, b: number) => number;
24
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
25
+ export const __externref_table_dealloc: (a: number) => void;
26
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
1
  {
2
- "name": "@peerbit/riblt",
3
- "version": "1.0.2",
4
- "description": "Riblt",
5
- "sideEffects": false,
6
- "type": "module",
7
- "types": "./dist/riblt.d.ts",
8
- "typesVersions": {
9
- "*": {
10
- "*": [
11
- "*",
12
- "dist/*",
13
- "dist/*/index"
14
- ],
15
- "src/*": [
16
- "*",
17
- "dist/*",
18
- "dist/*/index"
19
- ]
20
- }
21
- },
22
- "files": [
23
- "src",
24
- "dist",
25
- "!dist/test",
26
- "!**/*.tsbuildinfo"
27
- ],
28
- "exports": {
29
- ".": {
30
- "types": "./dist/riblt.d.ts",
31
- "import": "./dist/riblt.js"
32
- }
33
- },
34
- "eslintConfig": {
35
- "extends": "peerbit",
36
- "parserOptions": {
37
- "project": true,
38
- "sourceType": "module"
39
- },
40
- "ignorePatterns": [
41
- "!.aegir.js",
42
- "test/ts-use",
43
- "*.d.ts"
44
- ]
45
- },
46
- "publishConfig": {
47
- "access": "public"
48
- },
49
- "scripts": {
50
- "benchmark": "cargo bench",
51
- "clean": "cargo clear",
52
- "build": "wasm-pack build --target web --out-dir dist && shx rm -rf ./dist/package.json",
53
- "test": "cargo test && aegir test",
54
- "lint": "cargo fmt"
55
- },
56
- "author": "dao.xyz",
57
- "license": "MIT"
2
+ "name": "@peerbit/riblt",
3
+ "version": "1.0.3-e5f6c17",
4
+ "description": "Riblt",
5
+ "sideEffects": false,
6
+ "type": "module",
7
+ "types": "./dist/index.d.ts",
8
+ "typesVersions": {
9
+ "*": {
10
+ "*": [
11
+ "*",
12
+ "dist/*",
13
+ "dist/*/index"
14
+ ],
15
+ "src/*": [
16
+ "*",
17
+ "dist/*",
18
+ "dist/*/index"
19
+ ]
20
+ }
21
+ },
22
+ "files": [
23
+ "src",
24
+ "dist",
25
+ "!dist/test",
26
+ "!**/*.tsbuildinfo"
27
+ ],
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ }
33
+ },
34
+ "eslintConfig": {
35
+ "extends": "peerbit",
36
+ "parserOptions": {
37
+ "project": true,
38
+ "sourceType": "module"
39
+ },
40
+ "ignorePatterns": [
41
+ "!.aegir.js",
42
+ "test/ts-use",
43
+ "*.d.ts"
44
+ ]
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "scripts": {
50
+ "benchmark": "cargo bench",
51
+ "clean": "cargo clear",
52
+ "build": "wasm-pack build --target web --out-dir dist --out-name index && shx rm -rf ./dist/.gitignore && shx rm -rf ./dist/package.json",
53
+ "test": "cargo test && aegir test",
54
+ "lint": "cargo fmt"
55
+ },
56
+ "author": "dao.xyz",
57
+ "license": "MIT"
58
58
  }