mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-19 22:26:18 +00:00
32 lines
686 B
JavaScript
32 lines
686 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/splitbefore.js
|
|
type: application/javascript
|
|
module-type: filteroperator
|
|
|
|
Filter operator that splits each result on the first occurance of the specified separator and returns the unique values.
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.splitbefore = function(source,operator,options) {
|
|
var results = [];
|
|
source(function(tiddler,title) {
|
|
var parts = title.split(operator.operand);
|
|
if(parts.length === 1) {
|
|
$tw.utils.pushTop(results,parts[0]);
|
|
} else {
|
|
$tw.utils.pushTop(results,parts[0] + operator.operand);
|
|
}
|
|
});
|
|
return results;
|
|
};
|
|
|
|
})();
|