describe('default connection url', () => { it('is a static member on the class', () => { assert.ok(_isString(WSv2.url) && !_isEmpty(WSv2.url)) }) })
const validArg = v => _isString(v) && !_isEmpty(v)
/** * @private */ _onWSOpen () { this._isOpen = true this._isReconnecting = false this._packetWDLastTS = Date.now() this._lastAuthSeq = -1 this._lastPubSeq = -1 this.emit('open') if (!_isEmpty(this._prevChannelMap)) { this.resubscribePreviousChannels() this._prevChannelMap = {} } debug('connection open') }
/*! * * Provides a convenience extension to _.isEmpty which allows for * determining an object as being empty based on either the default * implementation or by evaluating each property to undefined, in * which case the object is considered empty. */ _.mixin(function () { // reference the original implementation var _isEmpty = _.isEmpty return { // If defined is true, and value is an object, object is considered // to be empty if all properties are undefined, otherwise the default // implementation is invoked. isEmpty: function (value, defined) { if (defined && _.isObject(value)) { return !_.some(value, function (value, key) { return value !== undefined }) } return _isEmpty(value) } } }())
/** * @param {Array} payload - payload to verify * @param {object} filter - filter to match against payload * @returns {boolean} pass * @private */ static _payloadPassesFilter (payload, filter) { const filterIndices = Object.keys(filter) let filterValue for (let k = 0; k < filterIndices.length; k++) { filterValue = filter[filterIndices[k]] if (_isEmpty(filterValue) || filterValue === '*') { continue } if (payload[+filterIndices[k]] !== filterValue) { return false } } return true }
const orders = _isEmpty(filterByMarket) ? allOrders : allOrders.filter(o => o.symbol === filterByMarket)
const initAuthArgs = ws.getAuthArgs() assert(_isObject(initAuthArgs) && _isEmpty(initAuthArgs)) })
assert.ok(_isString(args.url) && !_isEmpty(args.url), 'connection url not pulled from env') assert.strictEqual(args.url, url, 'provided url does not match env var') })
const { market } = params if (_isEmpty(market)) { return debug('market required')
const orders = _isEmpty(filterByMarket) ? allOrders : allOrders.filter(o => o.symbol === filterByMarket)
const { filterByMarket } = params const allPositions = await rest.positions() const positions = _isEmpty(filterByMarket) ? allPositions : allPositions.filter(({ symbol }) => symbol === filterByMarket)
const { market } = params if (_isEmpty(market)) { throw new Error('market required')
const { market } = params if (_isEmpty(market)) { throw new Error('market required')
const { symbol } = params if (_isEmpty(symbol)) { return debug('symbol required')