1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Add new "count" filter operator

See discussion here:
https://groups.google.com/d/msgid/tiddlywiki/fe51b7f5-5369-493b-82e5-94c
18e863fe0%40googlegroups.com?utm_medium=email&utm_source=footer
This commit is contained in:
Jermolene 2017-02-08 20:11:44 +00:00
parent 9bc523fdef
commit 73ded6a82a
3 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,26 @@
/*\
title: $:/core/modules/filters/count.js
type: application/javascript
module-type: filteroperator
Filter operator returning the number of entries in the current list.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Export our filter function
*/
exports.count = function(source,operator,options) {
var count = 0;
source(function(tiddler,title) {
count++;
});
return [count + ""];
};
})();

View File

@ -0,0 +1,13 @@
caption: count
created: 20170208200553517
modified: 20170208200900081
op-input: a [[selection of titles|Title Selection]]
op-output: a new list containing the number of items in the input list as a decimal string
op-purpose: count the number of entries in a list
tags: [[Filter Operators]] [[Group Operators]]
title: count Operator
type: text/vnd.tiddlywiki
The number of the entries in the input list is counted and a decimal representation returned as a single string.
<<.operator-examples "count">>

View File

@ -0,0 +1,7 @@
created: 20170208200912602
modified: 20170208201020488
tags: [[each Operator]] [[Operator Examples]]
title: count Operator (Examples)
type: text/vnd.tiddlywiki
<<.operator-example 1 "[tag[HelloThere]count[]]">>