diff --git a/core/modules/filters/minlength.js b/core/modules/filters/minlength.js new file mode 100644 index 000000000..d4e679bef --- /dev/null +++ b/core/modules/filters/minlength.js @@ -0,0 +1,29 @@ +/*\ +title: $:/core/modules/filters/minlength.js +type: application/javascript +module-type: filteroperator + +Filter operator for filtering out titles that don't meet the minimum length in the operand + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.minlength = function(source,operator,options) { + var results = [], + minLength = parseInt(operator.operand || "",10) || 0; + source(function(tiddler,title) { + if(title.length >= minLength) { + results.push(title); + } + }); + return results; +}; + +})(); diff --git a/editions/tw5.com/tiddlers/filters/examples/minlength.tid b/editions/tw5.com/tiddlers/filters/examples/minlength.tid new file mode 100644 index 000000000..fcad1bd50 --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/examples/minlength.tid @@ -0,0 +1,11 @@ +created: 20161011074235805 +modified: 20161011074235805 +tags: [[Operator Examples]] [[minlength Operator]] +title: minlength Operator (Examples) +type: text/vnd.tiddlywiki + +<<.using-days-of-week>> + +<<.operator-example 1 "[list[Days of the Week]minlength[7]]">> +<<.operator-example 2 "[list[Days of the Week]minlength[1]]">> + diff --git a/editions/tw5.com/tiddlers/filters/minlength.tid b/editions/tw5.com/tiddlers/filters/minlength.tid new file mode 100644 index 000000000..d450df35f --- /dev/null +++ b/editions/tw5.com/tiddlers/filters/minlength.tid @@ -0,0 +1,14 @@ +caption: minlength +created: 20161011074235805 +modified: 20161011074235805 +op-input: a list of items +op-output: those items at least as long as the specified minimum length +op-parameter: the minimum length for items +op-parameter-name: minlength +op-purpose: filter items shorter than the specified minimum length +from-version: 5.1.14 +tags: [[Filter Operators]] +title: minlength Operator +type: text/vnd.tiddlywiki + +<<.operator-examples "minlength">>