mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
33 lines
706 B
JavaScript
33 lines
706 B
JavaScript
|
/*\
|
||
|
title: $:/core/modules/filterrunprefixes/then.js
|
||
|
type: application/javascript
|
||
|
module-type: filterrunprefix
|
||
|
|
||
|
Replace results of previous runs unless empty
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
/*
|
||
|
Export our filter prefix function
|
||
|
*/
|
||
|
exports.then = function(operationSubFunction) {
|
||
|
return function(results,source,widget) {
|
||
|
if(results.length !== 0) {
|
||
|
// Only run if previous run(s) produced results
|
||
|
var thisRunResult = operationSubFunction(source,widget);
|
||
|
if(thisRunResult.length !== 0) {
|
||
|
// Replace results only if this run actually produces a result
|
||
|
results.clear();
|
||
|
results.pushTop(thisRunResult);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
})();
|