@leofcoin/peernet 1.1.19 → 1.1.21

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.
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './peernet-173d15f5.js';
1
+ import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './peernet-83538246.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  function commonjsRequire(path) {
@@ -10624,6 +10624,29 @@ var p2pt_umd = {
10624
10624
  }
10625
10625
  }
10626
10626
 
10627
+ _trySend(peer, data) {
10628
+ let shouldTry = data.msg.length > 0;
10629
+ let chunks = 0;
10630
+ let remaining = '';
10631
+
10632
+ while (shouldTry) {
10633
+ data.c = chunks;
10634
+
10635
+ remaining = data.msg.slice(MAX_MESSAGE_LENGTH);
10636
+ data.msg = data.msg.slice(0, MAX_MESSAGE_LENGTH);
10637
+
10638
+ if (!remaining) { data.last = true; }
10639
+ if (peer.connected) {
10640
+ peer.send(JSON_MESSAGE_IDENTIFIER + JSON.stringify(data));
10641
+ data.msg = remaining;
10642
+ chunks++;
10643
+ shouldTry = data.msg.length > 0;
10644
+ } else {
10645
+ shouldTry = false;
10646
+ this._removePeer(peer);
10647
+ }
10648
+ }
10649
+ }
10627
10650
  /**
10628
10651
  * Send a msg and get response for it
10629
10652
  * @param Peer peer simple-peer object to send msg to
@@ -10664,21 +10687,7 @@ var p2pt_umd = {
10664
10687
  return reject(Error('Connection to peer closed' + e))
10665
10688
  }
10666
10689
 
10667
- let chunks = 0;
10668
- let remaining = '';
10669
- while (data.msg.length > 0) {
10670
- data.c = chunks;
10671
-
10672
- remaining = data.msg.slice(MAX_MESSAGE_LENGTH);
10673
- data.msg = data.msg.slice(0, MAX_MESSAGE_LENGTH);
10674
-
10675
- if (!remaining) { data.last = true; }
10676
-
10677
- peer.send(JSON_MESSAGE_IDENTIFIER + JSON.stringify(data));
10678
-
10679
- data.msg = remaining;
10680
- chunks++;
10681
- }
10690
+ this._trySend(peer, data);
10682
10691
 
10683
10692
  debug$2('sent a message to ' + peer.id);
10684
10693
  })
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-173d15f5.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-83538246.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-173d15f5.js';
1
+ import { F as FormatInterface } from './peernet-83538246.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  var proto$b = {