Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

utils.js links to sys.js instead of other way around

  • Loading branch information...
commit 2b8ab7e24f2abc92474f44aad796b263582ab5d4 1 parent 0329468
@ry ry authored
View
16 lib/http.js
@@ -1,4 +1,4 @@
-var utils = require("/utils.js");
+var sys = require("/sys.js");
var CRLF = "\r\n";
var STATUS_CODES = {
@@ -502,11 +502,11 @@ exports.createClient = function (port, host) {
client._pushRequest = function (req) {
req.addListener("flush", function () {
if (client.readyState == "closed") {
- //utils.debug("HTTP CLIENT request flush. reconnect. readyState = " + client.readyState);
+ //sys.debug("HTTP CLIENT request flush. reconnect. readyState = " + client.readyState);
client.connect(port, host); // reconnect
return;
}
- //utils.debug("client flush readyState = " + client.readyState);
+ //sys.debug("client flush readyState = " + client.readyState);
if (req == requests[0]) flushMessageQueue(client, [req]);
});
requests.push(req);
@@ -517,7 +517,7 @@ exports.createClient = function (port, host) {
});
client.addListener("eof", function () {
- //utils.debug("client got eof closing. readyState = " + client.readyState);
+ //sys.debug("client got eof closing. readyState = " + client.readyState);
client.close();
});
@@ -527,20 +527,20 @@ exports.createClient = function (port, host) {
return;
}
- //utils.debug("HTTP CLIENT onClose. readyState = " + client.readyState);
+ //sys.debug("HTTP CLIENT onClose. readyState = " + client.readyState);
// If there are more requests to handle, reconnect.
if (requests.length > 0 && client.readyState != "opening") {
- //utils.debug("HTTP CLIENT: reconnecting readyState = " + client.readyState);
+ //sys.debug("HTTP CLIENT: reconnecting readyState = " + client.readyState);
client.connect(port, host); // reconnect
}
});
createIncomingMessageStream(client, function (res) {
- //utils.debug("incoming response!");
+ //sys.debug("incoming response!");
res.addListener("complete", function ( ) {
- //utils.debug("request complete disconnecting. readyState = " + client.readyState);
+ //sys.debug("request complete disconnecting. readyState = " + client.readyState);
client.close();
});
View
22 lib/repl.js
@@ -1,9 +1,9 @@
// A repl library that you can include in your own code to get a runtime
// interface to your program. Just require("/repl.js").
-var utils = require("utils.js");
+var sys = require("/sys.js");
-utils.puts("Type '.help' for options.");
+sys.puts("Type '.help' for options.");
var buffered_cmd = '';
@@ -49,7 +49,7 @@ function readline (cmd) {
var ret = eval(buffered_cmd);
if (ret !== undefined) {
exports.scope['_'] = ret;
- utils.p(ret);
+ sys.p(ret);
}
}
@@ -60,9 +60,9 @@ function readline (cmd) {
} catch (e) {
// On error: Print the error and clear the buffer
if (e.stack) {
- utils.puts(e.stack);
+ sys.puts(e.stack);
} else {
- utils.puts(e.toString());
+ sys.puts(e.toString());
}
buffered_cmd = '';
}
@@ -75,7 +75,7 @@ function readline (cmd) {
* Used to display the prompt.
*/
function displayPrompt () {
- utils.print(buffered_cmd.length ? '... ' : exports.prompt);
+ sys.print(buffered_cmd.length ? '... ' : exports.prompt);
}
/**
@@ -91,7 +91,7 @@ function parseREPLKeyword (cmd) {
displayPrompt();
return true;
case ".clear":
- utils.puts("Clearing Scope...");
+ sys.puts("Clearing Scope...");
buffered_cmd = '';
exports.scope = {};
displayPrompt();
@@ -100,10 +100,10 @@ function parseREPLKeyword (cmd) {
node.stdio.close();
return true;
case ".help":
- utils.puts(".break\tSometimes you get stuck in a place you can't get out... This will get you out.");
- utils.puts(".clear\tBreak, and also clear the local scope.");
- utils.puts(".exit\tExit the prompt");
- utils.puts(".help\tShow repl options");
+ sys.puts(".break\tSometimes you get stuck in a place you can't get out... This will get you out.");
+ sys.puts(".clear\tBreak, and also clear the local scope.");
+ sys.puts(".exit\tExit the prompt");
+ sys.puts(".help\tShow repl options");
displayPrompt();
return true;
}
View
69 lib/sys.js
@@ -0,0 +1,69 @@
+exports.print = function (x) {
+ node.stdio.write(x);
+};
+
+exports.puts = function (x) {
+ node.stdio.write(x.toString() + "\n");
+};
+
+exports.debug = function (x) {
+ node.stdio.writeError("DEBUG: " + x.toString() + "\n");
+};
+
+exports.error = function (x) {
+ node.stdio.writeError(x.toString() + "\n");
+};
+
+/**
+ * Echos the value of a value. Trys to print the value out
+ * in the best way possible given the different types.
+ *
+ * @param {Object} value The object to print out
+ */
+exports.inspect = function (value) {
+ if (value === 0) return "0";
+ if (value === false) return "false";
+ if (value === "") return '""';
+ if (typeof(value) == "function") return "[Function]";
+ if (value === undefined) return;
+
+ try {
+ return JSON.stringify(value);
+ } catch (e) {
+ // TODO make this recusrive and do a partial JSON output of object.
+ if (e.message.search("circular")) {
+ return "[Circular Object]";
+ } else {
+ throw e;
+ }
+ }
+};
+
+exports.p = function (x) {
+ exports.error(exports.inspect(x));
+};
+
+exports.exec = function (command) {
+ var child = node.createChildProcess("/bin/sh", ["-c", command]);
+ var stdout = "";
+ var stderr = "";
+ var promise = new node.Promise();
+
+ child.addListener("output", function (chunk) {
+ if (chunk) stdout += chunk;
+ });
+
+ child.addListener("error", function (chunk) {
+ if (chunk) stderr += chunk;
+ });
+
+ child.addListener("exit", function (code) {
+ if (code == 0) {
+ promise.emitSuccess(stdout, stderr);
+ } else {
+ promise.emitError(code, stdout, stderr);
+ }
+ });
+
+ return promise;
+};
View
1  lib/sys.js
View
1  lib/utils.js
View
69 lib/utils.js
@@ -1,69 +0,0 @@
-exports.print = function (x) {
- node.stdio.write(x);
-};
-
-exports.puts = function (x) {
- node.stdio.write(x.toString() + "\n");
-};
-
-exports.debug = function (x) {
- node.stdio.writeError("DEBUG: " + x.toString() + "\n");
-};
-
-exports.error = function (x) {
- node.stdio.writeError(x.toString() + "\n");
-};
-
-/**
- * Echos the value of a value. Trys to print the value out
- * in the best way possible given the different types.
- *
- * @param {Object} value The object to print out
- */
-exports.inspect = function (value) {
- if (value === 0) return "0";
- if (value === false) return "false";
- if (value === "") return '""';
- if (typeof(value) == "function") return "[Function]";
- if (value === undefined) return;
-
- try {
- return JSON.stringify(value);
- } catch (e) {
- // TODO make this recusrive and do a partial JSON output of object.
- if (e.message.search("circular")) {
- return "[Circular Object]";
- } else {
- throw e;
- }
- }
-};
-
-exports.p = function (x) {
- exports.error(exports.inspect(x));
-};
-
-exports.exec = function (command) {
- var child = node.createChildProcess("/bin/sh", ["-c", command]);
- var stdout = "";
- var stderr = "";
- var promise = new node.Promise();
-
- child.addListener("output", function (chunk) {
- if (chunk) stdout += chunk;
- });
-
- child.addListener("error", function (chunk) {
- if (chunk) stderr += chunk;
- });
-
- child.addListener("exit", function (code) {
- if (code == 0) {
- promise.emitSuccess(stdout, stderr);
- } else {
- promise.emitError(code, stdout, stderr);
- }
- });
-
- return promise;
-};
View
2  src/node.js
@@ -24,7 +24,7 @@ node.createChildProcess = function (file, args, env) {
};
node.exec = function () {
- throw new Error("node.exec() has moved. Use require('/utils.js') to bring it back.");
+ throw new Error("node.exec() has moved. Use require('/sys.js') to bring it back.");
}
node.http.createServer = function () {
View
10 src/util.js
@@ -70,21 +70,21 @@ node.path = new function () {
puts = function () {
- throw new Error("puts() has moved. Use require('/utils.js') to bring it back.");
+ throw new Error("puts() has moved. Use require('/sys.js') to bring it back.");
}
print = function () {
- throw new Error("print() has moved. Use require('/utils.js') to bring it back.");
+ throw new Error("print() has moved. Use require('/sys.js') to bring it back.");
}
p = function () {
- throw new Error("p() has moved. Use require('/utils.js') to bring it back.");
+ throw new Error("p() has moved. Use require('/sys.js') to bring it back.");
}
node.debug = function () {
- throw new Error("node.debug() has moved. Use require('/utils.js') to bring it back.");
+ throw new Error("node.debug() has moved. Use require('/sys.js') to bring it back.");
}
node.error = function () {
- throw new Error("node.error() has moved. Use require('/utils.js') to bring it back.");
+ throw new Error("node.error() has moved. Use require('/sys.js') to bring it back.");
}
Please sign in to comment.
Something went wrong with that request. Please try again.