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 29bc735

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
console: fix console.table() display edge case
If the properties are not specified in `console.table()`, then we should make a best effort to determine them rather than put all values into a "Values" column. PR-URL: #20323 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent be34388 commit 29bc735
Copy full SHA for 29bc735

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+21
-14
lines changed
Open diff view settings
Collapse file

β€Žlib/console.jsβ€Ž

Copy file name to clipboardExpand all lines: lib/console.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,7 @@ Console.prototype.table = function(tabularData, properties) {
363363
tabularData = previewSetIterator(tabularData);
364364

365365
const setlike = setIter || isSet(tabularData);
366-
if (setlike ||
367-
(properties === undefined &&
368-
(isArray(tabularData) || isTypedArray(tabularData)))) {
366+
if (setlike) {
369367
const values = [];
370368
let length = 0;
371369
for (const v of tabularData) {
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-console-table.js
+20-11Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ test([1, 2, 3], `
4141
`);
4242

4343
test([Symbol(), 5, [10]], `
44-
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
45-
β”‚ (index) β”‚ Values β”‚
46-
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
47-
β”‚ 0 β”‚ Symbol() β”‚
48-
β”‚ 1 β”‚ 5 β”‚
49-
β”‚ 2 β”‚ [ 10 ] β”‚
50-
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
44+
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
45+
β”‚ (index) β”‚ 0 β”‚ Values β”‚
46+
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
47+
β”‚ 0 β”‚ β”‚ Symbol() β”‚
48+
β”‚ 1 β”‚ β”‚ 5 β”‚
49+
β”‚ 2 β”‚ 10 β”‚ β”‚
50+
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
5151
`);
5252

5353
test([undefined, 5], `
@@ -182,10 +182,10 @@ test({ a: undefined }, ['x'], `
182182
`);
183183

184184
test([], `
185-
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
186-
β”‚ (index) β”‚ Values β”‚
187-
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
188-
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
185+
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
186+
β”‚ (index) β”‚
187+
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
188+
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
189189
`);
190190

191191
test(new Map(), `
@@ -194,3 +194,12 @@ test(new Map(), `
194194
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€
195195
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜
196196
`);
197+
198+
test([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], `
199+
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”
200+
β”‚ (index) β”‚ a β”‚ b β”‚
201+
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€
202+
β”‚ 0 β”‚ 1 β”‚ 'Y' β”‚
203+
β”‚ 1 β”‚ 'Z' β”‚ 2 β”‚
204+
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”˜
205+
`);

0 commit comments

Comments
0Β (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.