Skip to content

Commit 5fc27cc

Browse files
authored
Fix node dbg() function to log undefined correctly (#25521)
Previously `dbg(1, 2, undefined)` would just print `1 2 `, not it printf `1 2 undefined` which is more like what console.warn does.
1 parent 5a8e1e8 commit 5fc27cc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/runtime_debug.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ function dbg(...args) {
1717
// TODO(sbc): Unify with err/out implementation in shell.sh.
1818
var fs = require('fs');
1919
var utils = require('util');
20-
var stringify = (a) => typeof a == 'object' ? utils.inspect(a) : a;
20+
function stringify(a) {
21+
switch (typeof a) {
22+
case 'object': return utils.inspect(a);
23+
case 'undefined': return 'undefined';
24+
}
25+
return a;
26+
}
2127
fs.writeSync(2, args.map(stringify).join(' ') + '\n');
2228
} else
2329
#endif

0 commit comments

Comments
 (0)