Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3fd6724

Browse filesBrowse 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 <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 3edb04d commit 3fd6724
Copy full SHA for 3fd6724

File tree

Expand file treeCollapse file tree

2 files changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎lib/console.js‎

Copy file name to clipboardExpand all lines: lib/console.js
+1-2Lines changed: 1 addition & 2 deletions
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');
Collapse file

‎test/parallel/test-console-table.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-console-table.js
+1Lines changed: 1 addition & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.