Created
July 23, 2010 15:45
-
-
Save polotek/487611 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/node.js b/src/node.js | |
index 914f02f..76b41be 100644 | |
--- a/src/node.js | |
+++ b/src/node.js | |
@@ -192,14 +192,16 @@ process.openStdin = function () { | |
// console object | |
function format (f) { | |
+ var sys = module.requireNative('sys'); | |
var i = 1; | |
var args = arguments; | |
if (!(f instanceof String)) f = String(f); | |
- return f.replace(/%([sdj])/g, function (x) { | |
+ return f.replace(/%([sdjk])/g, function (x) { | |
switch (x) { | |
case '%s': return args[i++]; | |
case '%d': return args[i++].toString(); | |
case '%j': return JSON.stringify(args[i++]); | |
+ case '%k': return sys.inspect(args[i++]); | |
default: | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment