Permalink
Browse files

If not string, console.log should just print it without trying to format

  • Loading branch information...
1 parent c9e1220 commit b69c6a03b18ff9dd496368c58ae5db3fa1fafe08 @ry ry committed Jun 29, 2010
Showing with 1 addition and 0 deletions.
  1. +1 −0 src/node.js
View
@@ -194,6 +194,7 @@ process.openStdin = function () {
function format (f) {
var i = 1;
var args = arguments;
+ if (!(f instanceof String)) return f;
return f.replace(/%([sdf])/g, function (x) {
switch (x) {
case '%s': return args[i++];

2 comments on commit b69c6a0

@tj
tj commented on b69c6a0 Jun 29, 2010

do you want my sprintf implementation for this?

@DmitryBaranovskiy

What if it is not string, but an object with meaningful toString method. Should you cut it down? May be just cast it to string String(f) and be whatever.

Please sign in to comment.