1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add new 'filter' prefix for filter runs (#4918)

This commit is contained in:
saqimtiaz 2020-10-27 17:48:40 +01:00 committed by GitHub
parent c9efa23f02
commit 972456ca07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,31 @@
/*\
title: $:/core/modules/filterrunprefixes/filter.js
type: application/javascript
module-type: filterrunprefix
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.filter = function(operationSubFunction) {
return function(results,source,widget) {
if(results.length > 0) {
var resultsToRemove = [];
$tw.utils.each(results,function(result) {
var filtered = operationSubFunction($tw.wiki.makeTiddlerIterator([result]),widget);
if(filtered.length === 0) {
resultsToRemove.push(result);
}
});
$tw.utils.removeArrayEntries(results,resultsToRemove);
}
}
};
})();