@syncot/connection
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -42,2 +42,3 @@ import { SyncOtEmitter } from '@syncot/util'; | ||
* How many times longer to wait on each subsequent reconnect attempt. | ||
* If set to 0, a random delay is used every time. | ||
* Default is 1.5. | ||
@@ -44,0 +45,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { SyncOtEmitter } from '@syncot/util'; | ||
import { randomInteger, SyncOtEmitter } from '@syncot/util'; | ||
import { strict as assert } from 'assert'; | ||
@@ -34,3 +34,4 @@ /** | ||
this.maxDelay >= this.minDelay, 'Argument "maxDelay" must be a safe integer >= minDelay.'); | ||
assert.ok(Number.isFinite(this.delayFactor) && this.delayFactor >= 1, 'Argument "delayFactor" must be a finite number >= 1.'); | ||
assert.ok(Number.isFinite(this.delayFactor) && | ||
(this.delayFactor >= 1 || this.delayFactor === 0), 'Argument "delayFactor" must be a finite number >= 1 or == 0.'); | ||
this.connection.on('connect', this.onConnect); | ||
@@ -74,3 +75,5 @@ this.connection.on('disconnect', this.onDisconnect); | ||
? 0 | ||
: Math.min(this.maxDelay, this.minDelay * Math.pow(this.delayFactor, this.attempt)); | ||
: this.delayFactor === 0 | ||
? randomInteger(this.minDelay, this.maxDelay) | ||
: Math.min(this.maxDelay, this.minDelay * Math.pow(this.delayFactor, this.attempt)); | ||
this.attempt++; | ||
@@ -77,0 +80,0 @@ this.scheduledConnect = setTimeout(() => { |
{ | ||
"name": "@syncot/connection", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "An RPC library for communication over Duplex object streams.", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "10a2aa8510e10b1ed034fa61a75d30dc1613e932" | ||
"gitHead": "38411f33bb5b260da49fbcd92c47157a4ee40c03" | ||
} |
37800
934