-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
console: console.table doesn't fall back to just logging when given a function #20679
Labels
console
Issues and PRs related to the console subsystem.
Comments
i think it'd be fine to change it |
ohbarye
added a commit
to ohbarye/node
that referenced
this issue
May 11, 2018
According to the [console.table document](https://github.com/nodejs/node/blob/master/doc/api/console.md#consoletabletabulardata-properties), 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. Fixes: nodejs#20679
3 tasks
I think this was intentional behavior. It's what Chrome does and it fits my interpretation of the spec. However, Firefox does it differently and the spec for Do note that it's possible to attach properties to a function and that our current implementation deals with that well: $ ./node
> foo = function () {}
[Function: foo]
> foo.bar = 'hey'
'hey'
> console.table(foo)
┌─────────┬────────┐
│ (index) │ Values │
├─────────┼────────┤
│ bar │ 'hey' │
└─────────┴────────┘
undefined
> |
MylesBorins
pushed a commit
that referenced
this issue
May 22, 2018
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>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a question. (And I admit it's a kind of nitpicking).
Current Behavior
According to the console.table document, 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.
I guess that's because the following line allows a function to proceed the consequent steps.
node/lib/console.js
Line 329 in 5096e24
Question
Is this intentional behavior?
If it's better to change this behavior, I would be glad to send a patch for that.
The text was updated successfully, but these errors were encountered: