1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-15 01:49:55 +00:00

Add compound iterators to boot wiki object

This commit is contained in:
Jermolene 2014-04-30 22:49:28 +01:00
parent fcb26419a6
commit bd3e955821

View File

@ -885,6 +885,33 @@ $tw.Wiki = function(options) {
}
};
// Iterate through all tiddlers and then the shadows
this.eachTiddlerPlusShadows = function(callback) {
for(var title in tiddlers) {
callback(tiddlers[title],title);
}
for(var title in shadowTiddlers) {
if(!Object.prototype.hasOwnProperty.call(tiddlers,title)) {
var shadowInfo = shadowTiddlers[title];
callback(shadowInfo.tiddler,title);
}
}
};
// Iterate through all the shadows and then the tiddlers
this.eachShadowPlusTiddlers = function(callback) {
for(var title in shadowTiddlers) {
var shadowInfo = shadowTiddlers[title];
callback(shadowInfo.tiddler,title);
}
for(var title in tiddlers) {
if(!Object.prototype.hasOwnProperty.call(shadowTiddlers,title)) {
callback(tiddlers[title],title);
}
}
};
// Test for the existence of a tiddler
this.tiddlerExists = function(title) {
return !!$tw.utils.hop(tiddlers,title);