Check listeners length before removeAllListeners, fixing possible WebPack EventEmitter bug

This commit is contained in:
wltsmrz
2014-08-18 17:21:08 -07:00
parent 989509dc07
commit 40dc49bd63

View File

@@ -186,8 +186,10 @@ OrderBook.prototype.unsubscribe = function() {
this._shouldSubscribe = false;
OrderBook.EVENTS.forEach(function(event) {
this.removeAllListeners(event);
}, this);
if (self.listeners(event).length > 0) {
self.removeAllListeners(event);
}
});
this.emit('unsubscribe');
};
@@ -366,6 +368,10 @@ OrderBook.prototype.setFundedAmount = function(offer, fundedAmount) {
return offer;
}
function sixFigures(str) {
return str.substring(0, str.indexOf('.') + 7);
};
var takerGetsValue = (typeof offer.TakerGets === 'object')
? offer.TakerGets.value
: offer.TakerGets;