1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-01 09:43:16 +00:00
TiddlyWiki5/core/modules/filters/after.js

32 lines
638 B
JavaScript
Raw Normal View History

/*\
title: $:/core/modules/filters/after.js
type: application/javascript
module-type: filteroperator
Filter operator returning the tiddler from the current list that is after the tiddler named in the operand.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.after = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
results.push(title);
});
var index = results.indexOf(operator.operand);
if(index === -1 || index > (results.length - 2)) {
return [];
} else {
return [results[index + 1]];
}
};
})();