-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
util: if present, fallback to toString
using the %s formatter
#27621
Conversation
@nodejs/util PTAL |
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.
Change seems reasonable to me otherwise, pending Anna's comments.
72e1b7e
to
9700e97
Compare
@nodejs/util PTAL |
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.
LGTM but can you explain why we don't move this check to util.inspect
?
@silverwind that would be quite a big breaking change and I doubt that we actually profit from that. It reminds me of our original The reason why I opened this PR is to keep the behavior backwards compatible (using |
@nodejs/util PTAL. This could use another review. |
This includes the information that some inputs are handled differently than others (e.g., `Symbols` are partially represented as `NaN`).
This makes sure that `util.format` uses `String` to stringify an object in case the object has an own property named `toString` with type `function`. That way objects that do not have such function are still inspected using `util.inspect` and the old behavior is preserved as well.
9700e97
to
0bb8a7f
Compare
Rebased due to a92ad36. |
This includes the information that some inputs are handled differently than others (e.g., `Symbols` are partially represented as `NaN`). PR-URL: nodejs#27621 Reviewed-By: Roman Reiss <me@silverwind.io>
This makes sure that `util.format` uses `String` to stringify an object in case the object has an own property named `toString` with type `function`. That way objects that do not have such function are still inspected using `util.inspect` and the old behavior is preserved as well. PR-URL: nodejs#27621 Refs: jestjs/jest#8443 Reviewed-By: Roman Reiss <me@silverwind.io>
This includes the information that some inputs are handled differently than others (e.g., `Symbols` are partially represented as `NaN`). PR-URL: #27621 Reviewed-By: Roman Reiss <me@silverwind.io>
This makes sure that `util.format` uses `String` to stringify an object in case the object has an own property named `toString` with type `function`. That way objects that do not have such function are still inspected using `util.inspect` and the old behavior is preserved as well. PR-URL: #27621 Refs: jestjs/jest#8443 Reviewed-By: Roman Reiss <me@silverwind.io>
This makes sure that
util.format
usesString
to stringify an objectin case the object has an own property named
toString
with typefunction
. That way objects that do not have such function are stillinspected using
util.inspect
and the old behavior is preserved aswell.
Refs: jestjs/jest#8443
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes