Skip to content

Instantly share code, notes, and snippets.

@polotek
Created July 23, 2010 15:45
Show Gist options
  • Save polotek/487611 to your computer and use it in GitHub Desktop.
Save polotek/487611 to your computer and use it in GitHub Desktop.
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