Skip to content

Commit 0c852a1

Browse files
ohbaryeBridgeAR
authored andcommitted
console: .table fall back to logging for function too
According to the console.table documentation, it reads that it "falls back to just logging the argument if it can’t be parsed as tabular." But it doesn't fall back when I give a function as its first argument. It logs an empty table. This is fixes by this commit. PR-URL: #20681 Fixes: #20679 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 60cc8ff commit 0c852a1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

β€Žlib/console.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ Console.prototype.table = function(tabularData, properties) {
327327
if (properties !== undefined && !ArrayIsArray(properties))
328328
throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties);
329329

330-
if (tabularData == null ||
331-
(typeof tabularData !== 'object' && typeof tabularData !== 'function'))
330+
if (tabularData == null || typeof tabularData !== 'object')
332331
return this.log(tabularData);
333332

334333
if (cliTable === undefined) cliTable = require('internal/cli_table');

β€Žtest/parallel/test-console-table.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ test(undefined, 'undefined\n');
2929
test(false, 'false\n');
3030
test('hi', 'hi\n');
3131
test(Symbol(), 'Symbol()\n');
32+
test(function() {}, '[Function]\n');
3233

3334
test([1, 2, 3], `
3435
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”

0 commit comments

Comments
Β (0)