Minor refactoring, including switching to strict mode

print-window-tiddler
Jeremy Ruston 2011-11-30 17:27:00 +00:00
rodzic 2e9f334eca
commit b907d846f3
12 zmienionych plików z 37 dodań i 12 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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".
*/
"use strict";
var fs = require("fs"),
path = require("path"),
url = require("url"),

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -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.
*/
"use strict";
var utils = exports;
// Pad a string to a certain length with zeros

Wyświetl plik

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