From 21b2d6fdc7684cd90c609101dc35dfe41cb7aa22 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 30 Apr 2014 22:50:17 +0100 Subject: [PATCH] Allow filter operators to return an iterator Previously filter operators were only permitted to return an array of tiddler titles --- core/modules/filters.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/modules/filters.js b/core/modules/filters.js index b8ca1dae6..474928ba7 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -203,9 +203,21 @@ exports.compileFilter = function(filterString) { wiki: self, widget: widget }); - accumulator = self.makeTiddlerIterator(results); + if($tw.utils.isArray(results)) { + accumulator = self.makeTiddlerIterator(results); + } else { + accumulator = results; + } }); - return results; + if($tw.utils.isArray(results)) { + return results; + } else { + var resultArray = []; + results(function(tiddler,title) { + resultArray.push(title); + }); + return resultArray; + } }; // Wrap the operator functions in a wrapper function that depends on the prefix operationFunctions.push((function() {