Selaa lähdekoodia

refs #5123: Updated with new EOF check

Jared Hall 11 vuotta sitten
vanhempi
commit
4a90f048c0
2 muutettua tiedostoa jossa 3 lisäystä ja 3 poistoa
  1. 2 2
      lib/pipeline/Pipeline.js
  2. 1 1
      test/lib/pipeline/Pipeline.js

+ 2 - 2
lib/pipeline/Pipeline.js

@@ -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);

+ 1 - 1
test/lib/pipeline/Pipeline.js

@@ -35,7 +35,7 @@ module.exports = {
 				};
 				
 				proto.getNext = function(callback){
-					var answer = this.current > 0 ? {val:this.current--} : null;
+					var answer = this.current > 0 ? {val:this.current--} : DocumentSource.EOF;
 					if(callback) {
 						return callback(null, answer);
 					} else {