Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let data = getMessagePayload(msg)
if (this._manageOrderBooks) {
const err = this._updateManagedOB(symbol, data, raw)
if (err) {
this.emit('error', err)
return
}
data = this._orderBooks[symbol]
}
// Always transform an array of entries
if (this._transform) {
data = new OrderBook((Array.isArray(data[0]) ? data : [data]), raw)
}
const internalMessage = [chanData.chanId, 'orderbook', data]
internalMessage.filterOverride = [
chanData.symbol,
chanData.prec,
chanData.len
]
this._propagateMessageToListeners(internalMessage, chanData, false)
this.emit('orderbook', symbol, data)
}
getOB (symbol) {
if (!this._orderBooks[symbol]) return null
return new OrderBook(this._orderBooks[symbol])
}