1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-28 15:08:46 +00:00

Minor refactoring, including switching to strict mode

This commit is contained in:
Jeremy Ruston 2011-11-30 17:27:00 +00:00
parent 2e9f334eca
commit b907d846f3
12 changed files with 37 additions and 12 deletions

View File

@ -2,6 +2,8 @@
// //
// Usage: node cook.js <recipefile> // Usage: node cook.js <recipefile>
"use strict";
var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki, var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
Recipe = require("./js/Recipe.js").Recipe, Recipe = require("./js/Recipe.js").Recipe,
util = require("util"); util = require("util");

View File

@ -5,6 +5,9 @@
// The .html extension is optional // The .html extension is optional
// //
// Ginsu creates the specified places the .tid files in the specified directory (which must already exist) // Ginsu creates the specified places the .tid files in the specified directory (which must already exist)
"use strict";
var fs = require("fs"), var fs = require("fs"),
path = require("path"), path = require("path"),
Tiddler = require("./js/Tiddler.js").Tiddler, Tiddler = require("./js/Tiddler.js").Tiddler,

View File

@ -17,6 +17,8 @@ Options and their defaults are:
*/ */
"use strict";
var ArgParser = function(argString,options) { var ArgParser = function(argString,options) {
var parseToken = function(match,p) { var parseToken = function(match,p) {
var n; var n;
@ -35,16 +37,16 @@ var ArgParser = function(argString,options) {
return n; return n;
}; };
this.byPos = []; this.byPos = [];
var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")"; var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")",
var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')"; sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')",
var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])"; dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])",
var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})"; dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})",
var unQuoted = options.noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)"; unQuoted = options.noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)",
var emptyQuote = "((?:\"\")|(?:''))"; emptyQuote = "((?:\"\")|(?:''))",
var skipSpace = "(?:\\s*)"; skipSpace = "(?:\\s*)",
var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")"; token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")",
var re = options.noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg"); re = options.noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg"),
var match; match;
do { do {
match = re.exec(argString); match = re.exec(argString);
if(match) { if(match) {
@ -69,8 +71,8 @@ var ArgParser = function(argString,options) {
} while(match); } while(match);
this.byName = {}; this.byName = {};
for(var t=0; t<this.byPos.length; t++) { for(var t=0; t<this.byPos.length; t++) {
var n = this.byPos[t].n; var n = this.byPos[t].n,
var v = this.byPos[t].v; v = this.byPos[t].v;
if(n in this.byName) if(n in this.byName)
this.byName[n].push(v); this.byName[n].push(v);
else else

View File

@ -3,6 +3,8 @@ FileRetriever can asynchronously retrieve files from HTTP URLs or the local file
throttling so that we don't get error EMFILE "Too many open files". throttling so that we don't get error EMFILE "Too many open files".
*/ */
"use strict";
var fs = require("fs"), var fs = require("fs"),
path = require("path"), path = require("path"),
url = require("url"), url = require("url"),

View File

@ -27,6 +27,8 @@ this.ingredients = {
*/ */
"use strict";
var Tiddler = require("./Tiddler.js").Tiddler, var Tiddler = require("./Tiddler.js").Tiddler,
tiddlerInput = require("./TiddlerInput.js"), tiddlerInput = require("./TiddlerInput.js"),
tiddlerOutput = require("./TiddlerOutput.js"), tiddlerOutput = require("./TiddlerOutput.js"),

View File

@ -14,6 +14,8 @@ Tiddler.fields - hashmap of tiddler fields
*/ */
"use strict";
var Tiddler = function(/* tiddler,fields */) { var Tiddler = function(/* tiddler,fields */) {
var tiddler, fields, c = 0, t; var tiddler, fields, c = 0, t;
if(arguments[c] instanceof Tiddler) { if(arguments[c] instanceof Tiddler) {

View File

@ -2,6 +2,8 @@
Functions concerned with parsing representations of tiddlers Functions concerned with parsing representations of tiddlers
*/ */
"use strict";
var ArgParser = require("./ArgParser.js").ArgParser, var ArgParser = require("./ArgParser.js").ArgParser,
utils = require("./Utils.js"), utils = require("./Utils.js"),
util = require("util"); util = require("util");

View File

@ -2,6 +2,8 @@
Functions concerned with parsing representations of tiddlers Functions concerned with parsing representations of tiddlers
*/ */
"use strict";
var utils = require("./Utils.js"); var utils = require("./Utils.js");
var tiddlerOutput = exports; var tiddlerOutput = exports;

View File

@ -1,3 +1,5 @@
"use strict";
var Tiddler = require("./Tiddler.js").Tiddler; var Tiddler = require("./Tiddler.js").Tiddler;
var TiddlyWiki = function() { var TiddlyWiki = function() {

View File

@ -2,6 +2,8 @@
Functions concerned with parsing TiddlyWiki files Functions concerned with parsing TiddlyWiki files
*/ */
"use strict";
var tiddlerInput = require("./TiddlerInput.js"), var tiddlerInput = require("./TiddlerInput.js"),
utils = require("./Utils.js"); utils = require("./Utils.js");

View File

@ -4,6 +4,8 @@ Various static utility functions.
This file is a bit of a dumping ground; the expectation is that most of these functions will be refactored. This file is a bit of a dumping ground; the expectation is that most of these functions will be refactored.
*/ */
"use strict";
var utils = exports; var utils = exports;
// Pad a string to a certain length with zeros // Pad a string to a certain length with zeros

View File

@ -2,6 +2,8 @@
// //
// Usage: node server.js <recipefile> // Usage: node server.js <recipefile>
"use strict";
var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki, var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
Recipe = require("./js/Recipe.js").Recipe, Recipe = require("./js/Recipe.js").Recipe,
http = require("http"), http = require("http"),