Skip to content

Commit 3fd6724

Browse files
ohbaryeMylesBorins
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 3edb04d commit 3fd6724

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
@@ -323,8 +323,7 @@ Console.prototype.table = function(tabularData, properties) {
323323
if (properties !== undefined && !ArrayIsArray(properties))
324324
throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties);
325325

326-
if (tabularData == null ||
327-
(typeof tabularData !== 'object' && typeof tabularData !== 'function'))
326+
if (tabularData == null || typeof tabularData !== 'object')
328327
return this.log(tabularData);
329328

330329
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)