Created
July 23, 2010 17:51
-
-
Save polotek/487786 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
// console object | |
function format (f) { | |
var sys = module.requireNative('sys'); | |
var args = new Array(arguments.length); | |
for(var i = 0, len = arguments.length, a; i<len; i++) { | |
a = arguments[i]; | |
sys.puts([i, len, a].join(' ')); | |
switch (typeof a) { | |
case 'string': | |
args.push(a); | |
break; | |
case 'object': | |
args.push(sys.inspect(a)); | |
break; | |
case 'undefined': | |
break; | |
default: | |
args.push(a.toString()); | |
} | |
} | |
sys.puts(sys.inspect(args)); | |
sys.puts(args.length); | |
return args.join(' '); | |
} |
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
var undef | |
, nil = null; | |
console.log('num:', 2 | |
, 'bool', true | |
, 'null:', nil | |
, 'undefined:', undef | |
, 'json:', {"foo":"bar"} | |
, 'object:', new require('events').EventEmitter()); | |
// Output | |
// num: 2 bool true null: null undefined: json: { foo: 'bar' } object: { EventEmitter: [Function], Promise: [Function] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment