mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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: https://github.com/nodejs/node/pull/20681 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
1 parent
3edb04d065
commit
3fd67249df
2 files changed
+2
-2
No files matched your search
+1
-2
@@ -323,8 +323,7 @@ Console.prototype.table = function(tabularData, properties) {
|
||||
if (properties !== undefined && !ArrayIsArray(properties))
|
||||
throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties);
|
||||
|
||||
if (tabularData == null ||
|
||||
(typeof tabularData !== 'object' && typeof tabularData !== 'function'))
|
||||
if (tabularData == null || typeof tabularData !== 'object')
|
||||
return this.log(tabularData);
|
||||
|
||||
if (cliTable === undefined) cliTable = require('internal/cli_table');
|
||||
|
||||
@@ -29,6 +29,7 @@ test(undefined, 'undefined\n');
|
||||
test(false, 'false\n');
|
||||
test('hi', 'hi\n');
|
||||
test(Symbol(), 'Symbol()\n');
|
||||
test(function() {}, '[Function]\n');
|
||||
|
||||
test([1, 2, 3], `
|
||||
┌─────────┬────────┐
|
||||
|
||||
Reference in new issue
Block a user