瀏覽代碼

EAGLESIX-3077: Added code for interrupt as suggested per PR

David Aebersold 11 年之前
父節點
當前提交
f027344447
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      lib/pipeline/documentSources/LimitDocumentSource.js

+ 3 - 0
lib/pipeline/documentSources/LimitDocumentSource.js

@@ -52,6 +52,9 @@ proto.coalesce = function coalesce(nextSource) {
 proto.getNext = function getNext(callback) {
 	if (!callback) throw new Error(this.getSourceName() + ' #getNext() requires callback');
 
+	if (this.expCtx instanceof Object && this.expCtx.checkForInterrupt && this.expCtx.checkForInterrupt() === false)
+		return callback(new Error("Interrupted"));
+
 	if (++this.count > this.limit) {
 		this.source.dispose();
 		callback(null, DocumentSource.EOF);