Comparing version 2.0.0-1 to 2.0.0-2
@@ -50,2 +50,4 @@ // Generated by CoffeeScript 1.7.0 | ||
this._cbQueue = []; | ||
this._closeCb = null; | ||
this._closeCbPromise = null; | ||
this.next = this._next; | ||
@@ -215,26 +217,33 @@ this.each = this._each; | ||
IterableResult.prototype.close = varar(0, 1, function(cb) { | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
if (_this._endFlag === true) { | ||
return resolve(); | ||
} else if (_this._closeCb == null) { | ||
_this._closeCb = function(err) { | ||
while (_this._cbQueue.length > 0) { | ||
_this._cbQueue.shift(); | ||
} | ||
_this._outstandingRequests = 0; | ||
if (err) { | ||
return reject(err); | ||
} else { | ||
return resolve(); | ||
} | ||
if (this._closeCbPromise != null) { | ||
if (this._closeCbPromise.isPending()) { | ||
this._closeCbPromise = this._closeCbPromise.nodeify(cb); | ||
} else { | ||
this._closeCbPromise = Promise.resolve().nodeify(cb); | ||
} | ||
} else { | ||
if (this._endFlag) { | ||
this._closeCbPromise = Promise.resolve().nodeify(cb); | ||
} else { | ||
this._closeCbPromise = new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
_this._closeCb = function(err) { | ||
while (_this._cbQueue.length > 0) { | ||
_this._cbQueue.shift(); | ||
} | ||
_this._outstandingRequests = 0; | ||
if (err) { | ||
return reject(err); | ||
} else { | ||
return resolve(); | ||
} | ||
}; | ||
_this._closeAsap = true; | ||
_this._outstandingRequests += 1; | ||
return _this._conn._endQuery(_this._token); | ||
}; | ||
_this._closeAsap = true; | ||
_this._outstandingRequests += 1; | ||
return _this._conn._endQuery(_this._token); | ||
} else { | ||
return _this.emit('error', new err.RqlDriverError("This shouldn't happen")); | ||
} | ||
}; | ||
})(this)).nodeify(cb); | ||
})(this)).nodeify(cb); | ||
} | ||
} | ||
return this._closeCbPromise; | ||
}); | ||
@@ -241,0 +250,0 @@ |
@@ -570,4 +570,7 @@ // Generated by CoffeeScript 1.7.0 | ||
_this.rawSocket.once("close", function() { | ||
var _ref; | ||
closeCb(); | ||
_this.rawSocket.removeAllListeners(); | ||
if ((_ref = _this.rawSocket) != null) { | ||
_ref.removeAllListeners(); | ||
} | ||
return _this.rawSocket = null; | ||
@@ -574,0 +577,0 @@ }); |
{ "name" : "rethinkdb" | ||
, "version" : "2.0.0-1" | ||
, "version" : "2.0.0-2" | ||
, "main" : "rethinkdb" | ||
@@ -4,0 +4,0 @@ , "description" : "This package provides the JavaScript driver library for the RethinkDB database server for use either from node or your web-browser." |
182103
5297