hyoo_sync_client 0.0.586 → 0.0.588

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.mjs CHANGED
@@ -294,11 +294,13 @@ var $node = new Proxy({ require }, {
294
294
  get(target, name, wrapper) {
295
295
  if (target[name])
296
296
  return target[name];
297
- const mod = target.require('module');
298
- if (mod.builtinModules.indexOf(name) >= 0)
297
+ if (name.startsWith('node:'))
299
298
  return target.require(name);
300
299
  if (name[0] === '.')
301
300
  return target.require(name);
301
+ const mod = target.require('module');
302
+ if (mod.builtinModules.indexOf(name) >= 0)
303
+ return target.require(name);
302
304
  try {
303
305
  target.require.resolve(name);
304
306
  }
@@ -453,9 +455,8 @@ var $;
453
455
  if (sub_pos !== end) {
454
456
  this.peer_move(end, sub_pos);
455
457
  }
456
- this.data.pop();
457
- this.data.pop();
458
- if (this.data.length === this.sub_from)
458
+ this.data.length = end;
459
+ if (end === this.sub_from)
459
460
  this.reap();
460
461
  }
461
462
  reap() { }
@@ -687,9 +688,8 @@ var $;
687
688
  const sub = this.data[cursor];
688
689
  const pos = this.data[cursor + 1];
689
690
  sub.pub_off(pos);
690
- this.data.pop();
691
- this.data.pop();
692
691
  }
692
+ this.data.length = this.sub_from;
693
693
  this.cursor = this.pub_from;
694
694
  this.track_cut();
695
695
  this.cursor = $mol_wire_cursor.final;
@@ -698,23 +698,15 @@ var $;
698
698
  if (this.cursor < this.pub_from) {
699
699
  $mol_fail(new Error('Cut of non begun sub'));
700
700
  }
701
- let tail = 0;
701
+ let end = this.data.length;
702
702
  for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
703
703
  const pub = this.data[cursor];
704
704
  pub?.sub_off(this.data[cursor + 1]);
705
- if (this.sub_from < this.data.length) {
706
- this.peer_move(this.data.length - 2, cursor);
707
- this.data.pop();
708
- this.data.pop();
709
- }
710
- else {
711
- ++tail;
712
- }
713
- }
714
- for (; tail; --tail) {
715
- this.data.pop();
716
- this.data.pop();
705
+ end -= 2;
706
+ if (this.sub_from <= end)
707
+ this.peer_move(end, cursor);
717
708
  }
709
+ this.data.length = end;
718
710
  this.sub_from = this.cursor;
719
711
  }
720
712
  complete() { }
package/node.test.js CHANGED
@@ -285,11 +285,13 @@ var $node = new Proxy({ require }, {
285
285
  get(target, name, wrapper) {
286
286
  if (target[name])
287
287
  return target[name];
288
- const mod = target.require('module');
289
- if (mod.builtinModules.indexOf(name) >= 0)
288
+ if (name.startsWith('node:'))
290
289
  return target.require(name);
291
290
  if (name[0] === '.')
292
291
  return target.require(name);
292
+ const mod = target.require('module');
293
+ if (mod.builtinModules.indexOf(name) >= 0)
294
+ return target.require(name);
293
295
  try {
294
296
  target.require.resolve(name);
295
297
  }
@@ -444,9 +446,8 @@ var $;
444
446
  if (sub_pos !== end) {
445
447
  this.peer_move(end, sub_pos);
446
448
  }
447
- this.data.pop();
448
- this.data.pop();
449
- if (this.data.length === this.sub_from)
449
+ this.data.length = end;
450
+ if (end === this.sub_from)
450
451
  this.reap();
451
452
  }
452
453
  reap() { }
@@ -678,9 +679,8 @@ var $;
678
679
  const sub = this.data[cursor];
679
680
  const pos = this.data[cursor + 1];
680
681
  sub.pub_off(pos);
681
- this.data.pop();
682
- this.data.pop();
683
682
  }
683
+ this.data.length = this.sub_from;
684
684
  this.cursor = this.pub_from;
685
685
  this.track_cut();
686
686
  this.cursor = $mol_wire_cursor.final;
@@ -689,23 +689,15 @@ var $;
689
689
  if (this.cursor < this.pub_from) {
690
690
  $mol_fail(new Error('Cut of non begun sub'));
691
691
  }
692
- let tail = 0;
692
+ let end = this.data.length;
693
693
  for (let cursor = this.cursor; cursor < this.sub_from; cursor += 2) {
694
694
  const pub = this.data[cursor];
695
695
  pub?.sub_off(this.data[cursor + 1]);
696
- if (this.sub_from < this.data.length) {
697
- this.peer_move(this.data.length - 2, cursor);
698
- this.data.pop();
699
- this.data.pop();
700
- }
701
- else {
702
- ++tail;
703
- }
704
- }
705
- for (; tail; --tail) {
706
- this.data.pop();
707
- this.data.pop();
696
+ end -= 2;
697
+ if (this.sub_from <= end)
698
+ this.peer_move(end, cursor);
708
699
  }
700
+ this.data.length = end;
709
701
  this.sub_from = this.cursor;
710
702
  }
711
703
  complete() { }