The name of it is "datebefore". For each tiddler passed as input, the filter checks the date in the tiddler's "created" field, or a different field if specified by the suffix, and passes it through if it is before the date given as a parameter. The ! prefix can reverse its meaning.
The filter can be found at http://afeldspar.tiddlyspot.com/#%24%3A%2Ffilters%2Fafeldspar%2Fdatebefore.js . Please let me know what you think. I'm also thinking that I might write a "how to write a filter operator" document based on what I learned to make this one, but I'm not sure where it should go after that, and it should definitely be reviewed by someone who actually understands why, for instance, that "/* jslint node: true, browser: true */" is there.
operator.operand
source(function(tiddler,title) { if (tiddler) { var tiddate = tiddler.getFieldString(fieldname); if (isNegated ? tiddate >= operand :tiddate < operand) { results.push(title); } } });
I know many people wrote their filter functions this way but this creates rendundant code. Would be better to simply use something like this:
Never seen or generated any performance test results myself however:Jeremy claims it will be significantly more performant without the extra conditional.
IMO avoiding redundancy is worth more than the minimal speed increment that results from a single comparison step.
On this level one could also argue that it is not optimal to use ".forEach()" instead of a plain js for-loop since it will execute a function on every iteration step (in this case the performance drawback can be reduced by the optimizing compiler though, but this depends on the browser and whether the api-user provided callback function can be optimized).
Also what could be done to increment the speed of filters is to cache all object properties like e.g. "operator.operand.length" and access them as variables in the iterator function.
-Felix
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/BLU436-SMTP127B8EEA7905F12B83198CECE300%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.