Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
util: add inspect.defaultOptions#8013
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
doc/api/util.md Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a defaultOptions setter/getter would be better here? Something like...
util.inspect.defaultOptions=options;// or even...util.inspect.defaultOptions.maxArrayLength=1000;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, seems cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think it might be possible to make them plain properties. Would save some time having to compute the getter/setter names at least.
jasnell commented Aug 8, 2016
I'm generally +1 on having this, but prefer making it a getter/setter rather than a method. |
lib/util.js Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this check for null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, null is an issue. How about a strict object check instead?
if(Object.prototype.toString.call(options)==='[object Object]'){There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places in core, I believe we've just been doing options === null || typeof options !== 'object'
silverwind commented Aug 8, 2016
Thanks for review. What's the general consensus on |
cjihrig commented Aug 8, 2016
Last I heard, we were still preferring |
jbergstroem commented Aug 8, 2016
Windows fail looks unrelated (Jenkins -- connection aborted) |
silverwind commented Aug 8, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Also, not sure what's up with the linter on CI:
|
silverwind commented Aug 8, 2016
Nevermind, there's some lint errors. Fixing them. |
silverwind commented Aug 8, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Updated to use the
|
jasnell commented Aug 8, 2016
Using a getter/setter would help protect against things like I'm not convinced that sealing the object is necessary but it's likely harmless. |
silverwind commented Aug 8, 2016
@jasnell Sealing for example prevents Supporting both |
silverwind commented Aug 8, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@jasnell I've switched to accessors now. The solution turned out shorter than I thought and should satisfy all cases. I'd like to keep the properties sealed to prevent some misuse like deleting, and so I can |
silverwind commented Aug 8, 2016
doc/api/util.md Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/options/default options
jasnell commented Aug 8, 2016
LGTM with a nit if CI is green. |
test/parallel/test-util-inspect.js Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit, but could you capitalize "set" here and in the comment below.
cjihrig commented Aug 8, 2016
LGTM pending CI. |
silverwind commented Aug 8, 2016
CI is green except a hanging Windows box. Giving this PR a bit of time for others to weight in. |
doc/api/util.md Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a property and not a function, it doesn't really "return" anything, right? It just is a value. I'd be inclined to delete the line entirely. I don't think it actually adds any information. (I also think it's misleading. If you don't set it, it's undefined and not an object.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Whoops, the parenthetical is wrong, ignore it. Also, uh, yeah, looks like I'm commenting on an out-of-date diff. SMH. Sorry.)
evanlucas commented Aug 9, 2016
LGTM with Trott's nit fixed |
silverwind commented Aug 9, 2016
Nit addressed. One more CI: https://ci.nodejs.org/job/node-test-pull-request/3589/ |
jasnell commented Aug 9, 2016
still LGTM :-) |
silverwind commented Aug 9, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Noticed a bug where the REPL module called to util.inspect(obj,undefined,undefined,true)The One last CI:
|
jasnell commented Aug 9, 2016
oh, good catch @silverwind |
Adds util.inspect.defaultOptions which allows customization of the default util.inspect options, which is useful for functions like console.log or util.format which implicitly call into util.inspect. PR-URL: nodejs#8013Fixes: nodejs#7566 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Adds util.inspect.defaultOptions which allows customization of the default util.inspect options, which is useful for functions like console.log or util.format which implicitly call into util.inspect. PR-URL: #8013Fixes: #7566 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
silverwind commented Aug 9, 2016 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Adds util.inspect.defaultOptions which allows customization of the default util.inspect options, which is useful for functions like console.log or util.format which implicitly call into util.inspect. PR-URL: #8013Fixes: #7566 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
silverwind commented Aug 9, 2016
There was a silly typo in the error message. I |
Adds util.inspect.defaultOptions which allows customization of the default util.inspect options, which is useful for functions like console.log or util.format which implicitly call into util.inspect. PR-URL: #8013Fixes: #7566 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
Notable changes: * build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) #7983 and #7576 * child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) #7811 and #7838 * fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) #7942 * repl: The REPL now supports editor mode. (Prince J Wesley) #7275 * util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) #8013 Refs: #8020 PR-URL: #8070
Notable changes: * build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) #7983 and #7576 * child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) #7811 and #7838 * child_process: argv[0] can now be set to arbitrary values in spawned processes. (Pat Pannuto) #7696 * fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) #7942 * repl: The REPL now supports editor mode. (Prince J Wesley) #7275 * util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) #8013 Refs: #8020 PR-URL: #8070
Notable changes: * build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) #7983 and #7576 * child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) #7811 and #7838 * child_process: argv[0] can now be set to arbitrary values in spawned processes. (Pat Pannuto) #7696 * fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) #7942 * repl: The REPL now supports editor mode. (Prince J Wesley) #7275 * util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) #8013 Refs: #8020 PR-URL: #8070
Notable changes: * build: zlib symbols and additional OpenSSL symbols are now exposed on Windows platforms. (Alex Hultman) nodejs#7983 and nodejs#7576 * child_process, cluster: Forked child processes and cluster workers now support stdio configuration. (Colin Ihrig) nodejs#7811 and nodejs#7838 * child_process: argv[0] can now be set to arbitrary values in spawned processes. (Pat Pannuto) nodejs#7696 * fs: fs.ReadStream now exposes the number of bytes it has read so far. (Linus Unnebäck) nodejs#7942 * repl: The REPL now supports editor mode. (Prince J Wesley) nodejs#7275 * util: inspect() can now be configured globally using util.inspect.defaultOptions. (Roman Reiss) nodejs#8013 Refs: nodejs#8020 PR-URL: nodejs#8070
Checklist
make -j4 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
util
Description of change
Adds the
util.inspect.config()method to allow customization of inspect options in cases whereutil.inspect()is implicitly called by core like inconsoleorutil.format.Fixes: #7566