|
|
@@ -369,7 +369,7 @@ proto._runSync = function _runSync() {
|
|
|
var resultArray = [],
|
|
|
finalSource = this._getFinalSource(),
|
|
|
next = finalSource.getNext();
|
|
|
- while(next) {
|
|
|
+ while(next !== DocumentSource.EOF) {
|
|
|
// add the document to the result set
|
|
|
resultArray.push(next);
|
|
|
next = finalSource.getNext();
|
|
|
@@ -388,7 +388,7 @@ proto._runAsync = function _runAsync(callback) {
|
|
|
finalSource = this._getFinalSource(),
|
|
|
gotNext = function(err, doc) {
|
|
|
if(err) return callback(err);
|
|
|
- if(doc) {
|
|
|
+ if(doc !== DocumentSource.EOF) {
|
|
|
resultArray.push(doc);
|
|
|
return setImmediate(function() { //setImmediate to avoid callstack size issues
|
|
|
finalSource.getNext(gotNext);
|