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
print-window-tiddler
Jermolene 2017-02-08 20:11:44 +00:00
rodzic 9bc523fdef
commit 73ded6a82a
3 zmienionych plików z 46 dodań i 0 usunięć

Wyświetl plik

@ -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 + ""];
};
})();

Wyświetl plik

@ -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">>

Wyświetl plik

@ -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[]]">>