Skip to content

Commit 727c5f8

Browse files
f3rnoJacobPlaster
authored andcommitted
(refactor) rm default auth() dms and calc params, use only if provided
1 parent 4fc33e3 commit 727c5f8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/ws2_manager.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const { EventEmitter } = require('events')
44
const debug = require('debug')('bfx:ws2:manager')
55
const _isEqual = require('lodash/isEqual')
6+
const _isFinite = require('lodash/isFinite')
67
const _includes = require('lodash/includes')
78
const _pick = require('lodash/pick')
89
const PromiseThrottle = require('promise-throttle')
@@ -116,19 +117,17 @@ class WS2Manager extends EventEmitter {
116117
* @param {Object?} args.calc - default 0
117118
* @param {Object?} args.dms - dead man switch, active 4
118119
*/
119-
auth ({ apiKey, apiSecret, calc = 0, dms = 0 } = {}) {
120+
auth ({ apiKey, apiSecret, calc, dms } = {}) {
120121
if (this._socketArgs.apiKey || this._socketArgs.apiSecret) {
121122
debug('error: auth credentials already provided! refusing auth')
122123
return
123124
}
124125

125126
this._socketArgs.apiKey = apiKey
126127
this._socketArgs.apiSecret = apiSecret
127-
this._authArgs = {
128-
...this._authArgs,
129-
calc,
130-
dms,
131-
}
128+
129+
if (_isFinite(calc)) this._authArgs.calc = calc
130+
if (_isFinite(dms)) this._authArgs.dms = dms
132131

133132
this._sockets.forEach(s => {
134133
if (!s.ws.isAuthenticated()) {

0 commit comments

Comments
 (0)