1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-25 23:03:15 +00:00
TiddlyWiki5/core/modules/filters/tags.js
Jermolene c6e48ebc2d Performance optimisations
In some situations, I’m seeing x2.5 speedups with these optimisations

Starts fixing #1864
2015-07-05 19:47:44 +01:00

32 lines
606 B
JavaScript

/*\
title: $:/core/modules/filters/tags.js
type: application/javascript
module-type: filteroperator
Filter operator returning all the tags of the selected tiddlers
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.tags = function(source,operator,options) {
var tags = {};
source(function(tiddler,title) {
var t, length;
if(tiddler && tiddler.fields.tags) {
for(t=0, length=tiddler.fields.tags.length; t<length; t++) {
tags[tiddler.fields.tags[t]] = true;
}
}
});
return Object.keys(tags);
};
})();