mol_wire_lib 1.0.115 → 1.0.118
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/node.d.ts +2 -1
- package/node.deps.json +1 -1
- package/node.esm.js +51 -51
- package/node.esm.js.map +1 -1
- package/node.js +51 -51
- package/node.js.map +1 -1
- package/node.test.js +51 -51
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +2 -1
- package/web.deps.json +1 -1
- package/web.esm.js +51 -51
- package/web.esm.js.map +1 -1
- package/web.js +51 -51
- package/web.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -47,37 +47,38 @@ var $;
|
|
|
47
47
|
"use strict";
|
|
48
48
|
var $;
|
|
49
49
|
(function ($) {
|
|
50
|
-
class $mol_wire_pub extends
|
|
50
|
+
class $mol_wire_pub extends Object {
|
|
51
|
+
data = [];
|
|
51
52
|
static get [Symbol.species]() {
|
|
52
53
|
return Array;
|
|
53
54
|
}
|
|
54
55
|
sub_from = 0;
|
|
55
56
|
get sub_list() {
|
|
56
57
|
const res = [];
|
|
57
|
-
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
58
|
-
res.push(this[i]);
|
|
58
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
59
|
+
res.push(this.data[i]);
|
|
59
60
|
}
|
|
60
61
|
return res;
|
|
61
62
|
}
|
|
62
63
|
get sub_empty() {
|
|
63
|
-
return this.sub_from === this.length;
|
|
64
|
+
return this.sub_from === this.data.length;
|
|
64
65
|
}
|
|
65
66
|
sub_on(sub, pub_pos) {
|
|
66
|
-
const pos = this.length;
|
|
67
|
-
this.push(sub, pub_pos);
|
|
67
|
+
const pos = this.data.length;
|
|
68
|
+
this.data.push(sub, pub_pos);
|
|
68
69
|
return pos;
|
|
69
70
|
}
|
|
70
71
|
sub_off(sub_pos) {
|
|
71
|
-
if (!(sub_pos < this.length)) {
|
|
72
|
+
if (!(sub_pos < this.data.length)) {
|
|
72
73
|
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
73
74
|
}
|
|
74
|
-
const end = this.length - 2;
|
|
75
|
+
const end = this.data.length - 2;
|
|
75
76
|
if (sub_pos !== end) {
|
|
76
77
|
this.peer_move(end, sub_pos);
|
|
77
78
|
}
|
|
78
|
-
this.pop();
|
|
79
|
-
this.pop();
|
|
80
|
-
if (this.length === this.sub_from)
|
|
79
|
+
this.data.pop();
|
|
80
|
+
this.data.pop();
|
|
81
|
+
if (this.data.length === this.sub_from)
|
|
81
82
|
this.reap();
|
|
82
83
|
}
|
|
83
84
|
reap() { }
|
|
@@ -87,20 +88,20 @@ var $;
|
|
|
87
88
|
refresh() { }
|
|
88
89
|
complete() { }
|
|
89
90
|
emit(quant = $mol_wire_cursor.stale) {
|
|
90
|
-
for (let i = this.sub_from; i < this.length; i += 2) {
|
|
91
|
+
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
91
92
|
;
|
|
92
|
-
this[i].absorb(quant);
|
|
93
|
+
this.data[i].absorb(quant);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
peer_move(from_pos, to_pos) {
|
|
96
|
-
const peer = this[from_pos];
|
|
97
|
-
const self_pos = this[from_pos + 1];
|
|
98
|
-
this[to_pos] = peer;
|
|
99
|
-
this[to_pos + 1] = self_pos;
|
|
97
|
+
const peer = this.data[from_pos];
|
|
98
|
+
const self_pos = this.data[from_pos + 1];
|
|
99
|
+
this.data[to_pos] = peer;
|
|
100
|
+
this.data[to_pos + 1] = self_pos;
|
|
100
101
|
peer.peer_repos(self_pos, to_pos);
|
|
101
102
|
}
|
|
102
103
|
peer_repos(peer_pos, self_pos) {
|
|
103
|
-
this[peer_pos + 1] = self_pos;
|
|
104
|
+
this.data[peer_pos + 1] = self_pos;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
$.$mol_wire_pub = $mol_wire_pub;
|
|
@@ -232,7 +233,7 @@ var $;
|
|
|
232
233
|
const res = [];
|
|
233
234
|
const max = this.cursor >= 0 ? this.cursor : this.sub_from;
|
|
234
235
|
for (let i = this.pub_from; i < max; i += 2) {
|
|
235
|
-
res.push(this[i]);
|
|
236
|
+
res.push(this.data[i]);
|
|
236
237
|
}
|
|
237
238
|
return res;
|
|
238
239
|
}
|
|
@@ -252,7 +253,7 @@ var $;
|
|
|
252
253
|
if (this.cursor < 0)
|
|
253
254
|
$mol_fail(new Error('Promo to non begun sub'));
|
|
254
255
|
if (this.cursor < this.sub_from) {
|
|
255
|
-
const next = this[this.cursor];
|
|
256
|
+
const next = this.data[this.cursor];
|
|
256
257
|
if (pub === undefined)
|
|
257
258
|
return next ?? null;
|
|
258
259
|
if (next === pub) {
|
|
@@ -260,8 +261,8 @@ var $;
|
|
|
260
261
|
return next;
|
|
261
262
|
}
|
|
262
263
|
if (next) {
|
|
263
|
-
if (this.sub_from < this.length) {
|
|
264
|
-
this.peer_move(this.sub_from, this.length);
|
|
264
|
+
if (this.sub_from < this.data.length) {
|
|
265
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
265
266
|
}
|
|
266
267
|
this.peer_move(this.cursor, this.sub_from);
|
|
267
268
|
this.sub_from += 2;
|
|
@@ -270,13 +271,13 @@ var $;
|
|
|
270
271
|
else {
|
|
271
272
|
if (pub === undefined)
|
|
272
273
|
return null;
|
|
273
|
-
if (this.sub_from < this.length) {
|
|
274
|
-
this.peer_move(this.sub_from, this.length);
|
|
274
|
+
if (this.sub_from < this.data.length) {
|
|
275
|
+
this.peer_move(this.sub_from, this.data.length);
|
|
275
276
|
}
|
|
276
277
|
this.sub_from += 2;
|
|
277
278
|
}
|
|
278
|
-
this[this.cursor] = pub;
|
|
279
|
-
this[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
279
|
+
this.data[this.cursor] = pub;
|
|
280
|
+
this.data[this.cursor + 1] = pub.sub_on(this, this.cursor);
|
|
280
281
|
this.cursor += 2;
|
|
281
282
|
return pub;
|
|
282
283
|
}
|
|
@@ -286,22 +287,22 @@ var $;
|
|
|
286
287
|
$mol_fail(new Error('End of non begun sub'));
|
|
287
288
|
}
|
|
288
289
|
for (let cursor = this.pub_from; cursor < this.cursor; cursor += 2) {
|
|
289
|
-
const pub = this[cursor];
|
|
290
|
+
const pub = this.data[cursor];
|
|
290
291
|
pub.refresh();
|
|
291
292
|
}
|
|
292
293
|
this.cursor = $mol_wire_cursor.fresh;
|
|
293
294
|
}
|
|
294
295
|
pub_off(sub_pos) {
|
|
295
|
-
this[sub_pos] = undefined;
|
|
296
|
-
this[sub_pos + 1] = undefined;
|
|
296
|
+
this.data[sub_pos] = undefined;
|
|
297
|
+
this.data[sub_pos + 1] = undefined;
|
|
297
298
|
}
|
|
298
299
|
destructor() {
|
|
299
|
-
for (let cursor = this.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
300
|
-
const sub = this[cursor];
|
|
301
|
-
const pos = this[cursor + 1];
|
|
300
|
+
for (let cursor = this.data.length - 2; cursor >= this.sub_from; cursor -= 2) {
|
|
301
|
+
const sub = this.data[cursor];
|
|
302
|
+
const pos = this.data[cursor + 1];
|
|
302
303
|
sub.pub_off(pos);
|
|
303
|
-
this.pop();
|
|
304
|
-
this.pop();
|
|
304
|
+
this.data.pop();
|
|
305
|
+
this.data.pop();
|
|
305
306
|
}
|
|
306
307
|
this.cursor = this.pub_from;
|
|
307
308
|
this.track_cut();
|
|
@@ -313,20 +314,20 @@ var $;
|
|
|
313
314
|
}
|
|
314
315
|
let tail = 0;
|
|
315
316
|
for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
|
|
316
|
-
const pub = this[cursor];
|
|
317
|
-
pub?.sub_off(this[cursor + 1]);
|
|
318
|
-
if (this.sub_from < this.length) {
|
|
319
|
-
this.peer_move(this.length - 2, cursor);
|
|
320
|
-
this.pop();
|
|
321
|
-
this.pop();
|
|
317
|
+
const pub = this.data[cursor];
|
|
318
|
+
pub?.sub_off(this.data[cursor + 1]);
|
|
319
|
+
if (this.sub_from < this.data.length) {
|
|
320
|
+
this.peer_move(this.data.length - 2, cursor);
|
|
321
|
+
this.data.pop();
|
|
322
|
+
this.data.pop();
|
|
322
323
|
}
|
|
323
324
|
else {
|
|
324
325
|
++tail;
|
|
325
326
|
}
|
|
326
327
|
}
|
|
327
328
|
for (; tail; --tail) {
|
|
328
|
-
this.pop();
|
|
329
|
-
this.pop();
|
|
329
|
+
this.data.pop();
|
|
330
|
+
this.data.pop();
|
|
330
331
|
}
|
|
331
332
|
this.sub_from = this.cursor;
|
|
332
333
|
}
|
|
@@ -334,7 +335,7 @@ var $;
|
|
|
334
335
|
complete_pubs() {
|
|
335
336
|
const limit = this.cursor < 0 ? this.sub_from : this.cursor;
|
|
336
337
|
for (let cursor = this.pub_from; cursor < limit; cursor += 2) {
|
|
337
|
-
const pub = this[cursor];
|
|
338
|
+
const pub = this.data[cursor];
|
|
338
339
|
pub?.complete();
|
|
339
340
|
}
|
|
340
341
|
}
|
|
@@ -593,7 +594,7 @@ var $;
|
|
|
593
594
|
}
|
|
594
595
|
cache = undefined;
|
|
595
596
|
get args() {
|
|
596
|
-
return this.slice(0, this.pub_from);
|
|
597
|
+
return this.data.slice(0, this.pub_from);
|
|
597
598
|
}
|
|
598
599
|
result() {
|
|
599
600
|
if (this.cache instanceof Promise)
|
|
@@ -606,11 +607,10 @@ var $;
|
|
|
606
607
|
return this.task.name + '()';
|
|
607
608
|
}
|
|
608
609
|
constructor(id, task, host, ...args) {
|
|
609
|
-
super(
|
|
610
|
+
super();
|
|
610
611
|
this.task = task;
|
|
611
612
|
this.host = host;
|
|
612
|
-
this.
|
|
613
|
-
this.pop();
|
|
613
|
+
this.data.push(...args);
|
|
614
614
|
this.pub_from = this.sub_from = args.length;
|
|
615
615
|
this[Symbol.toStringTag] = id;
|
|
616
616
|
}
|
|
@@ -654,7 +654,7 @@ var $;
|
|
|
654
654
|
check: if (this.cursor === $mol_wire_cursor.doubt) {
|
|
655
655
|
for (let i = this.pub_from; i < this.sub_from; i += 2) {
|
|
656
656
|
;
|
|
657
|
-
this[i]?.refresh();
|
|
657
|
+
this.data[i]?.refresh();
|
|
658
658
|
if (this.cursor !== $mol_wire_cursor.doubt)
|
|
659
659
|
break check;
|
|
660
660
|
}
|
|
@@ -669,10 +669,10 @@ var $;
|
|
|
669
669
|
result = this.task.call(this.host);
|
|
670
670
|
break;
|
|
671
671
|
case 1:
|
|
672
|
-
result = this.task.call(this.host, this[0]);
|
|
672
|
+
result = this.task.call(this.host, this.data[0]);
|
|
673
673
|
break;
|
|
674
674
|
default:
|
|
675
|
-
result = this.task.call(this.host, ...this.slice(0, this.pub_from));
|
|
675
|
+
result = this.task.call(this.host, ...this.data.slice(0, this.pub_from));
|
|
676
676
|
break;
|
|
677
677
|
}
|
|
678
678
|
if (result instanceof Promise) {
|
|
@@ -1070,7 +1070,7 @@ var $;
|
|
|
1070
1070
|
}
|
|
1071
1071
|
catch { }
|
|
1072
1072
|
}
|
|
1073
|
-
if (this.sub_from < this.length) {
|
|
1073
|
+
if (this.sub_from < this.data.length) {
|
|
1074
1074
|
if (!$mol_compare_deep(prev, next)) {
|
|
1075
1075
|
this.emit();
|
|
1076
1076
|
}
|