1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00
TiddlyWiki5/js/Tiddler.js
2011-11-22 17:42:03 +00:00

35 lines
1.0 KiB
JavaScript
Executable File

/*
Tiddlers are an immutable dictionary of name:value pairs called fields. Values can be a string, an array
of strings, or a date.
Hardcoded in the system is the knowledge that the 'tags' field is a string array, and that the 'modified'
and 'created' fields are dates. All other fields are strings.
The Tiddler object exposes the following API
new Tiddler(fields) - create a Tiddler given a hashmap of field values
new Tiddler(tiddler,fields) - create a Tiddler from an existing tiddler with a hashmap of modified field values
Tiddler.fields - hashmap of tiddler fields
*/
var Tiddler = function(/* tiddler,fields */) {
var tiddler, fields, c = 0, t;
if(arguments[c] instanceof Tiddler) {
tiddler = arguments[c++];
}
fields = arguments[c++];
this.fields = {};
if(tiddler instanceof Tiddler) {
for(t in tiddler.fields) {
this.fields[t] = tiddler.fields[t]; // Should copy arrays by value
}
}
for(t in fields) {
this.fields[t] = fields[t]; // Should copy arrays by value
}
}
exports.Tiddler = Tiddler;