mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 23:03:50 +00:00
commit
e57148b034
@ -28,7 +28,7 @@ exports.limit = function(source,operator,options) {
|
|||||||
// Slice the array if necessary
|
// Slice the array if necessary
|
||||||
var limit = Math.min(source.length,parseInt(operator.operand,10));
|
var limit = Math.min(source.length,parseInt(operator.operand,10));
|
||||||
if(operator.prefix === "!") {
|
if(operator.prefix === "!") {
|
||||||
results = source.slice(source.length - limit,limit);
|
results = source.slice(source.length - limit);
|
||||||
} else {
|
} else {
|
||||||
results = source.slice(0,limit);
|
results = source.slice(0,limit);
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,7 @@ describe("Filter tests", function() {
|
|||||||
it("should handle the limit operator", function() {
|
it("should handle the limit operator", function() {
|
||||||
expect(wiki.filterTiddlers("[!is[system]sort[title]limit[2]]").join(",")).toBe("a fourth tiddler,one");
|
expect(wiki.filterTiddlers("[!is[system]sort[title]limit[2]]").join(",")).toBe("a fourth tiddler,one");
|
||||||
expect(wiki.filterTiddlers("[prefix[Tid]sort[title]limit[1]]").join(",")).toBe("Tiddler Three");
|
expect(wiki.filterTiddlers("[prefix[Tid]sort[title]limit[1]]").join(",")).toBe("Tiddler Three");
|
||||||
|
expect(wiki.filterTiddlers("[prefix[Tid]sort[title]!limit[1]]").join(",")).toBe("TiddlerOne");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle the list operator", function() {
|
it("should handle the list operator", function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user