1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-17 07:14:50 +00:00

Rename JSON operators

See https://github.com/Jermolene/TiddlyWiki5/pull/6522#issuecomment-1111206619
This commit is contained in:
jeremy@jermolene.com 2022-04-27 17:35:45 +01:00
parent 096b30f43b
commit 28f1d587b6
2 changed files with 41 additions and 41 deletions

View File

@ -12,7 +12,7 @@ Filter operators for JSON operations
/*global $tw: false */
"use strict";
exports["getjson"] = function(source,operator,options) {
exports["jsonget"] = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
var data = options.wiki.getTiddlerDataCached(title);
@ -26,7 +26,7 @@ exports["getjson"] = function(source,operator,options) {
return results;
};
exports["indexesjson"] = function(source,operator,options) {
exports["jsonindexes"] = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
var data = options.wiki.getTiddlerDataCached(title);
@ -40,7 +40,7 @@ exports["indexesjson"] = function(source,operator,options) {
return results;
};
exports["typejson"] = function(source,operator,options) {
exports["jsontype"] = function(source,operator,options) {
var results = [];
source(function(tiddler,title) {
var data = options.wiki.getTiddlerDataCached(title);

View File

@ -32,48 +32,48 @@ describe("json filter tests", function() {
expect(wiki.filterTiddlers("[[First]getindex[b]]")).toEqual([]);
});
it("should support the getjson operator", function() {
expect(wiki.filterTiddlers("[[First]getjson[]]")).toEqual(["one","","1.618","four","five","six","true","false","null"]);
expect(wiki.filterTiddlers("[[First]getjson[a]]")).toEqual(["one"]);
expect(wiki.filterTiddlers("[[First]getjson[b]]")).toEqual([""]);
expect(wiki.filterTiddlers("[[First]getjson[d]]")).toEqual(["four","five","six","true","false","null"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[e]]")).toEqual(["four"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[f]]")).toEqual(["five","six","true","false","null"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[f],[0]]")).toEqual(["five"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[f],[1]]")).toEqual(["six"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[f],[2]]")).toEqual(["true"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[f],[3]]")).toEqual(["false"]);
expect(wiki.filterTiddlers("[[First]getjson[d],[f],[4]]")).toEqual(["null"]);
it("should support the jsonget operator", function() {
expect(wiki.filterTiddlers("[[First]jsonget[]]")).toEqual(["one","","1.618","four","five","six","true","false","null"]);
expect(wiki.filterTiddlers("[[First]jsonget[a]]")).toEqual(["one"]);
expect(wiki.filterTiddlers("[[First]jsonget[b]]")).toEqual([""]);
expect(wiki.filterTiddlers("[[First]jsonget[d]]")).toEqual(["four","five","six","true","false","null"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[e]]")).toEqual(["four"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[f]]")).toEqual(["five","six","true","false","null"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[f],[0]]")).toEqual(["five"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[f],[1]]")).toEqual(["six"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[f],[2]]")).toEqual(["true"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[f],[3]]")).toEqual(["false"]);
expect(wiki.filterTiddlers("[[First]jsonget[d],[f],[4]]")).toEqual(["null"]);
});
it("should support the indexesjson operator", function() {
expect(wiki.filterTiddlers("[[Second]indexesjson[]]")).toEqual(["0","1","2"]);
expect(wiki.filterTiddlers("[[First]indexesjson[]]")).toEqual(["a","b","c","d"]);
expect(wiki.filterTiddlers("[[First]indexesjson[a]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[b]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[d]]")).toEqual(["e","f"]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[e]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[f]]")).toEqual(["0","1","2","3","4"]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[f],[0]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[f],[1]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[f],[2]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[f],[3]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]indexesjson[d],[f],[4]]")).toEqual([]);
it("should support the jsonindexes operator", function() {
expect(wiki.filterTiddlers("[[Second]jsonindexes[]]")).toEqual(["0","1","2"]);
expect(wiki.filterTiddlers("[[First]jsonindexes[]]")).toEqual(["a","b","c","d"]);
expect(wiki.filterTiddlers("[[First]jsonindexes[a]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[b]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d]]")).toEqual(["e","f"]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[e]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[f]]")).toEqual(["0","1","2","3","4"]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[f],[0]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[f],[1]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[f],[2]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[f],[3]]")).toEqual([]);
expect(wiki.filterTiddlers("[[First]jsonindexes[d],[f],[4]]")).toEqual([]);
});
it("should support the typejson operator", function() {
expect(wiki.filterTiddlers("[[First]typejson[]]")).toEqual(["object"]);
expect(wiki.filterTiddlers("[[First]typejson[a]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]typejson[b]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]typejson[c]]")).toEqual(["number"]);
expect(wiki.filterTiddlers("[[First]typejson[d]]")).toEqual(["object"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[e]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[f]]")).toEqual(["array"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[f],[0]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[f],[1]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[f],[2]]")).toEqual(["boolean"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[f],[3]]")).toEqual(["boolean"]);
expect(wiki.filterTiddlers("[[First]typejson[d],[f],[4]]")).toEqual(["null"]);
it("should support the jsontype operator", function() {
expect(wiki.filterTiddlers("[[First]jsontype[]]")).toEqual(["object"]);
expect(wiki.filterTiddlers("[[First]jsontype[a]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]jsontype[b]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]jsontype[c]]")).toEqual(["number"]);
expect(wiki.filterTiddlers("[[First]jsontype[d]]")).toEqual(["object"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[e]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[f]]")).toEqual(["array"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[f],[0]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[f],[1]]")).toEqual(["string"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[f],[2]]")).toEqual(["boolean"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[f],[3]]")).toEqual(["boolean"]);
expect(wiki.filterTiddlers("[[First]jsontype[d],[f],[4]]")).toEqual(["null"]);
});
});