Browse Source

Add node.error(); p() outputs to stderr.

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
949f24305b
  1. 18
      src/util.js

18
src/util.js

@ -99,16 +99,20 @@ puts = function (x) {
print(x.toString() + "\n");
};
node.debug = function (x) {
node.stdio.writeError("DEBUG: " + x.toString() + "\n");
};
node.error = function (x) {
node.stdio.writeError(x.toString() + "\n");
};
p = function (x) {
if (x === null) {
puts("null");
node.error("null");
} else if (x === NaN) {
puts("NaN");
node.error("NaN");
} else {
puts(JSON.stringify(x) || "undefined");
node.error(JSON.stringify(x) || "undefined");
}
};
node.debug = function (x) {
node.stdio.writeError("DEBUG: " + x.toString() + "\n");
};

Loading…
Cancel
Save