Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
If not string, console.log should just print it without trying to format
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 29, 2010
1 parent c9e1220 commit b69c6a0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/node.js
Expand Up @@ -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++];
Expand Down

2 comments on commit b69c6a0

@tj
Copy link

@tj tj commented on b69c6a0 Jun 29, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want my sprintf implementation for this?

@DmitryBaranovskiy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.