mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
f2d6c5a6eb
* 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
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);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
})();
|