Added multiple arg support for sys.puts(), print(), etc.
authorvisionmedia <tj@vision-media.ca>
Wed, 10 Feb 2010 01:27:23 +0000 (17:27 -0800)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 12 Feb 2010 18:43:07 +0000 (10:43 -0800)
lib/sys.js

index 461a12c..581af38 100644 (file)
@@ -1,11 +1,15 @@
 var events = require('events');
 
-exports.print = function (x) {
-  process.stdio.write(x);
+exports.print = function () {
+  for (var i = 0, len = arguments.length; i < len; ++i) {
+    process.stdio.write(arguments[i]);
+  }
 };
 
-exports.puts = function (x) {
-  process.stdio.write(x + "\n");
+exports.puts = function () {
+  for (var i = 0, len = arguments.length; i < len; ++i) {
+    process.stdio.write(arguments[i] + '\n');
+  }
 };
 
 exports.debug = function (x) {
@@ -13,7 +17,9 @@ exports.debug = function (x) {
 };
 
 exports.error = function (x) {
-  process.stdio.writeError(x + "\n");
+  for (var i = 0, len = arguments.length; i < len; ++i) {
+    process.stdio.writeError(arguments[i] + '\n');
+  }
 };
 
 /**
@@ -116,8 +122,10 @@ exports.inspect = function (obj, showHidden) {
   return format(obj);
 };
 
-exports.p = function (x) {
-  exports.error(exports.inspect(x));
+exports.p = function () {
+  for (var i = 0, len = arguments.length; i < len; ++i) {
+    exports.error(exports.inspect(arguments[i]));
+  }
 };
 
 exports.exec = function (command) {