1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-04 11:13:15 +00:00
TiddlyWiki5/core/modules/filterrunprefixes/then.js
yaisog f2d6c5a6eb
Add a :then filter run prefix (#7392)
* Initial commit

* Replace previous result only when non-empty

* Add doc tiddler

* Small change in rp-output description

* Update FRP title

lowercase with colon prefix

* Integrate with other doc tiddlers

* Add two doc-styles for reuse

* Add tests

* Add another test

* Correct indentation in stylesheet

* Change title and tags, add example to doc tiddler

* Replace leading spaces with tabs

* Improve docs text and structure
2023-06-24 18:07:34 +01:00

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);
}
}
};
};
})();